亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

linux分區大小調整完全手冊

系統 1922 0


環境
  服務器安裝有一個60G的硬盤,目前已劃分為/、/home、/chroot和/swap,周詳的分區信息怎么下所示:
Command (m for help): p
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?? Device Boot??? Start?????? End??? Blocks?? Id? System
/dev/hda1?? *???????? 1?????? 915?? 7349706?? 83? Linux
/dev/hda2?????????? 916????? 1414?? 4008217+? 83? Linux
/dev/hda3????????? 1415????? 7476? 48693015??? 5? Extended
/dev/hda5????????? 1415????? 1477??? 506016?? 82? Linux swap
/dev/hda6????????? 1478????? 7476? 48186936?? 83? Linux
  然后目前希望從/home分區里面分出大約4GB的空間用于安裝FreeBSD。
過程
  首先,我們需要調整文件系統的大小(注意是文件系統,而不是分區的大小),然后對調整完畢的文件系統進行檢查,然后再進一步調整分區的大小。
  文章以我自己用的系統為例子,實際操作時根據情況調整即可。
  用慣了傳統調整硬盤工具的人可能會認為文件系統和硬盤的分區之間是統一的,實際上他們之間并不是完整的整體(這也就是為什么BSD能在一個硬盤分區里面制作多個文件系統分區)。想像一下帶有移動式書架的書櫥。你能通過移動式書架調整書櫥里面書籍的位置。把書當成文件系統,你能在書櫥里面放滿書籍,也能通過移動式書架調整書櫥的空間。當然也能通過書架調整書櫥里面書籍存放的位置。如下圖所示:
??????? |;|;|
??????? +---------------+---------------+
??????? |XXXXXXXXXXXXXXX|XXXXXXXXXX|??? |
??????? |XXXXXXXXXXXXXXX|XXXXXXXXXX|??? |
??????? +---------------+---------------+
  硬盤分區/dev/hda1中的文件系統占滿了整個分區,而/dev/hda2中的文件系統只占用了2/3左右的分區。
  基本的原理就是這樣,目前讓我們開始調整/dev/hda6中文件系統的大小:
[root@ringmail root]# umount /home
[root@ringmail root]# resize_reiserfs -s 43000M /dev/hda6
;
reiserfsprogs 3.6.4
You are running BETA version of reiserfs shrinker.
This version is only for testing or VERY CAREFUL use.
Backup of you data is recommended.
Do you want to continue? [y/N]:y
Processing the tree: 0%
....20%....40%....60%....80%....100%???????????????????????? left 0, 301020 /sec
nodes processed (moved):
int??????? 56 (0),
leaves???? 8124 (0),
unfm?????? 6313240 (0),
total????? 6321420 (0).
check for used blocks in truncated region
ReiserFS report:
blocksize???????????? 4096
block count?????????? 11008000 (12046734)
free blocks?????????? 4678034 (5716736)
bitmap block count??? 336 (36

Syncing..done
  由于/home原來的大小是47057,而我們希望在/home里面劃分4G的空間出來,取整數/home的目標大小就是43000。所以在resize_reiserfs時為-s提供大小為43000M。
  這樣我們就已完成了文件系統大小調整的工作,下面讓我們計算一下目標分區的大小,這個大小需要根據你的fdisk里面的Units值來計算,因為硬盤分區都是按照柱面來劃分的,基本的計算方法為:43000*1024*1024/8225280=5481.7304699657640834111422346716,然后我們取最接近的值5482+1478=6960來作為分區結束的柱號,這里面的1478是/home分區開始的柱面號,在前面的fdisk里面能看到。
  調整完文件系統的大小以后,再使用以下命令以文件系統進行全方面的檢查:
[root@ringmail root]# reiserfsck --check --fix-fixable /dev/hda6
  目前我們已完成文件系統的大小調整工作,不過硬盤分區的大小仍然沒有調整,還是跟先前相同大(能想像我們從書櫥里面拿走了幾本書,而書架的大小并沒有調整,依然占用著原來的空間)。
  目前我們要開始進行整個操作里面最危險的操作:如果沒有必要的話,最佳不要進行下去

,不過不必過于擔心,按照以下操作進行即可。
  啟動fdisk,并按照以下步驟進行:
[root@ringmail root]# fdisk /dev/hda
The number of cylinders for this disk is set to 7476.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
?? (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?? Device Boot??? Start?????? End??? Blocks?? Id? System
/dev/hda1?? *???????? 1?????? 915?? 7349706?? 83? Linux
/dev/hda2?????????? 916????? 1414?? 4008217+? 83? Linux
/dev/hda3????????? 1415????? 7476? 48693015??? 5? Extended
/dev/hda5????????? 1415????? 1477??? 506016?? 82? Linux swap
/dev/hda6????????? 1478????? 7476? 48186936?? 83? Linux
Command (m for help): d
Partition number (1-6): 6
Command (m for help): n
Command action
?? l?? logical (5 or over)
?? p?? primary partition (1-4)
l
First cylinder (1478-7476, default 147

: 1478
Last cylinder or +size or +sizeM or +sizeK (1478-7476, default 7476): 6960
Command (m for help): p
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?? Device Boot??? Start?????? End??? Blocks?? Id? System
/dev/hda1?? *???????? 1?????? 915?? 7349706?? 83? Linux
/dev/hda2?????????? 916????? 1414?? 4008217+? 83? Linux
/dev/hda3????????? 1415????? 7476? 48693015??? 5? Extended
/dev/hda5????????? 1415????? 1477??? 506016?? 82? Linux swap
/dev/hda6????????? 1478????? 6960? 44042166?? 83? Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource
busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
  這里需要說明的是,由于內核仍然使用舊的分區表,我需要通過重新啟動才能刷新剛制作的分區信息,所以在進行完重劃分區操作以后,我對系統進行了重新啟操作。系統重啟后再繼續后續的操作過程。
  通過以上步驟,我們已完成了硬盤分區大小調整的操作,接下來回到重新調整文件系統大小的問題上來。由于硬盤分區是按照柱面來計劃的,我們要在resize_reiserfs步驟上就一步到位調整文件系統大小和硬盤分區大小正好相等是比較困難的事情。所以一般是調硬盤分區比文件系統要大一點點,然后再通過以下命令進行同步(當然如果你不在意硬盤分區里面存在部分空間的話也能忽略以下步驟):
[root@ringmail root]# umount /home/
[root@ringmail root]# resize_reiserfs /dev/hda6
;
reiserfsprogs 3.6.4
ReiserFS report:
blocksize???????????? 4096
block count?????????? 11010541 (11008000)
free blocks?????????? 4680574 (4678034)
bitmap block count??? 337 (336)
Syncing..done
  完成以后原有分區的大小調整操作已結束,接下來需要創建新分區:
[root@ringmail root]# fdisk /dev/hda
The number of cylinders for this disk is set to 7476.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
?? (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?? Device Boot??? Start?????? End??? Blocks?? Id? System
/dev/hda1?? *???????? 1?????? 915?? 7349706?? 83? Linux
/dev/hda2?????????? 916????? 1414?? 4008217+? 83? Linux
/dev/hda3????????? 1415????? 7476? 48693015??? 5? Extended
/dev/hda5????????? 1415????? 1477??? 506016?? 82? Linux swap
/dev/hda6????????? 1478????? 6960? 44042166?? 83? Linux
Command (m for help): n
Command action
?? l?? logical (5 or over)
?? p?? primary partition (1-4)
l
First cylinder (6961-7476, default 6961):
Using default value 6961
Last cylinder or +size or +sizeM or +sizeK (6961-7476, default 7476):
Using default value 7476
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): a5
Changed system type of partition 7 to a5 (FreeBSD)
Command (m for help): p
Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
?? Device Boot??? Start?????? End??? Blocks?? Id? System
/dev/hda1?? *???????? 1?????? 915?? 7349706?? 83? Linux
/dev/hda2?????????? 916????? 1414?? 4008217+? 83? Linux
/dev/hda3????????? 1415????? 7476? 48693015??? 5? Extended
/dev/hda5????????? 1415????? 1477??? 506016?? 82? Linux swap
/dev/hda6????????? 1478????? 6960? 44042166?? 83? Linux
/dev/hda7????????? 6961????? 7476?? 4144738+? a5? FreeBSD
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource
busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
  至此,整個調整分區大小及創建新分區的操作全部完成。
轉貼的,忘了在那看到的,所以作者不要見怪。呵呵

linux分區大小調整完全手冊


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩av成人 | 九色 91 | 久久亚洲国产中v天仙www | 一级毛片免费视频日本 | 久久这里有精品视频任我鲁 | 免费一级毛片在线播放不收费 | 久久久久久久蜜桃 | 国产精品久久久久久久久久妇女 | 国自产拍在线天天更新2019 | 毛片免费观看成人 | 国内精品一区二区 | 99热精品在线免费观看 | 理论片黄色 | 久久99国产综合色 | 免费深夜视频 | 久久久噜噜噜久久老司机 | 欧美国产精品日韩在线 | 成人啪啪免费看 | 亚洲精品九色在线网站 | 久久国产精品自在自线 | 精品伊人久久久久7777人 | 最新仑乱免费视频 | 国产精品偷伦视频免费观看的 | 欧美一区2区三区3区公司 | 手机看片日韩高清国产欧美 | 国产成人精品久久免费动漫 | 普通话对白国产情侣自啪 | 四虎成人免费网址在线 | 国产一区亚洲二区三区 | 日韩美女va在线毛片免费知 | 中文字幕一二区 | 久久爱伊人一区二区三区小说 | 国产第五页 | 99精品在线免费观看 | 亚洲 自拍 另类 制服在线 | 国产一毛片 | 久久精品国内偷自一区 | 在线精品国产第一页 | 久久国产欧美另类久久久 | 香蕉视频免费在线播放 | 国内久久久久高清影视 |