Linux下的分区工具
生活随笔
收集整理的這篇文章主要介紹了
Linux下的分区工具
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Linux下的分區(qū)工具
來源:http://www.cnblogs.com/rootq/articles/1487201.html [root@localhost gxlinux]# df -Th#查看已經(jīng)掛載上的文件分區(qū)大小以及格式(當(dāng)然你的系統(tǒng)必須有空閑的空間不用了)
文件系統(tǒng)??????類型??? 容量??已用 可用 已用% 掛載點(diǎn)
/dev/sda1?????ext3??? 2.9G??2.2G??505M??82% /
/dev/sda2?????ext3??? 965M???22M??894M???3% /home
tmpfs????????tmpfs??? 345M???12K??345M???1% /dev/shm
[root@localhost gxlinux]# /sbin/fdisk /dev/sda
#fdisk命令來進(jìn)行磁盤分區(qū)
#如果你有第二塊硬盤,那么后面的設(shè)備符號(hào)是/dev/sdb,第三塊以此類推
The number of cylinders for this disk is set to 1044.
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): m #查看fdisk命令的幫助
Command action
???a???toggle a bootable flag
???b???edit bsd disklabel
???c???toggle the dos compatibility flag
???d???delete a partition #刪除某個(gè)分區(qū)
???l???list known partition types
???m???print this menu
???n???add a new partition #增加新的分區(qū)
???o???create a new empty DOS partition table
???p???print the partition table #打印/查看分區(qū)表
???q???quit without saving changes #不保存退出
???s???create a new empty Sun disklabel
???t???change a partition's system id
???u???change display/entry units
???v???verify the partition table
???w???write table to disk and exit #保存退出
???x???extra functionality (experts only)
Command (m for help): p #打印/查看已有的分區(qū)表
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000e25d9
???Device Boot??????Start?????????End??????Blocks???Id??System
/dev/sda1???*???????????1?????????382?????3068383+??83??Linux
/dev/sda2???????????? 383?????????509?????1020127+??83??Linux
/dev/sda3???????????? 510?????????636?????1020127+??82??Linux swap / Solaris
Command (m for help): n #開始增加新的分區(qū)
Command action
???e???extended #擴(kuò)展分區(qū)
???p???primary partition (1-4) #主分區(qū),一塊硬盤中可以有4個(gè)主分區(qū)
#例如:XP下C盤為主分區(qū),DEF為邏輯分區(qū)(DEF合起來就是擴(kuò)展分區(qū))
e #增加擴(kuò)展分區(qū)
Selected partition 4 #分區(qū)4作為擴(kuò)展分區(qū),分區(qū)4開始是未分配空閑空間
First cylinder (637-1044, default 637): <Enter>
Using default value 637 #分區(qū)的開頭,1044是塊結(jié)尾
Last cylinder or +size or +sizeM or +sizeK (637-1044, default 1044): <Enter>
#也可在這里直接輸入想要建立分區(qū)的大小,比如+5000MB,表示建立5000MB大小的分區(qū)
Using default value 1044 #分區(qū)的結(jié)尾
Command (m for help): n #建立完擴(kuò)展分區(qū),然后建立邏輯分區(qū)
First cylinder (637-1044, default 637): <Enter>
Using default value 637
Last cylinder or +size or +sizeM or +sizeK (637-1044, default 1044): <Enter>
Using default value 1044
Command (m for help): p #建立完了邏輯分區(qū),打印/查看
#可以看到增加了一個(gè)分區(qū),邏輯分區(qū)是建立在擴(kuò)展分區(qū)上的
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000e25d9
???Device Boot??????Start?????????End??????Blocks???Id??System
/dev/sda1???*???????????1?????????382?????3068383+??83??Linux
/dev/sda2???????????? 383?????????509?????1020127+??83??Linux
/dev/sda3???????????? 510?????????636?????1020127+??82??Linux swap / Solaris
/dev/sda4???????????? 637????????1044?????3277260??? 5??Extended
/dev/sda5???????????? 637????????1044?????3277228+??83??Linux
Command (m for help): w #把新的分區(qū)表寫入并保存,記住一定要保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 設(shè)備或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost gxlinux]# df -Th
#因?yàn)檫@個(gè)時(shí)候還沒有掛載,所以在df命令下并不能看到新的分區(qū)
文件系統(tǒng)??????類型??? 容量??已用 可用 已用% 掛載點(diǎn)
/dev/sda1?????ext3??? 2.9G??2.2G??505M??82% /
/dev/sda2?????ext3??? 965M???22M??894M???3% /home
tmpfs????????tmpfs??? 345M???12K??345M???1% /dev/shm
[root@localhost gxlinux]# /sbin/mkfs.ext3 /dev/sda5
#在掛載之前應(yīng)該先格式化,比如ext2,ext3格式
#還可以使用/sbin/mkfs –t ext3 /dev/sda5
#其實(shí)我們已經(jīng)看到在fdisk命令中已經(jīng)自動(dòng)將其格式化為ext3格式了
mke2fs 1.40.2 (12-Jul-2007)
warning: 107 blocks unused.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
410400 inodes, 819200 blocks
40965 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=838860800
25 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks:
????????32768, 98304, 163840, 229376, 294912
Writing inode tables: done???????????????????????????
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.??Use tune2fs -c or -i to override.
[root@localhost gxlinux]# /sbin/e2label /dev/sda5 backup #給新分區(qū)添加一個(gè)標(biāo)簽
[root@localhost gxlinux]# mkdir /mnt/bak #創(chuàng)建目錄
[root@localhost gxlinux]# mount /dev/sda5 /mnt/bak #將新分區(qū)掛載到指定目錄上
[root@localhost gxlinux]# df -Th #這時(shí)候就可以看到掛載上了
文件系統(tǒng)??????類型??? 容量??已用 可用 已用% 掛載點(diǎn)
/dev/sda1?????ext3??? 2.9G??2.2G??505M??82% /
/dev/sda2?????ext3??? 965M???22M??894M???3% /home
tmpfs????????tmpfs??? 345M???12K??345M???1% /dev/shm
/dev/sda5?????ext3??? 3.1G???69M??2.9G???3% /mnt/bak
[root@localhost gxlinux]# vim /etc/fstab #添加一行到/etc/fstab中開機(jī)自動(dòng)掛載
#其實(shí)不用設(shè)置,系統(tǒng)也可以開機(jī)自動(dòng)掛載的,因?yàn)樗母袷礁鷏inux系統(tǒng)格式是一樣的
[root@localhost gxlinux]# cat /etc/fstab
LABEL=/?????????????????/???????????????????????ext3??? defaults????????1 1
LABEL=/home???????????? /home?????????????????? ext3??? defaults????????1 2
tmpfs?????????????????? /dev/shm??????????????? tmpfs???defaults????????0 0
devpts??????????????????/dev/pts??????????????? devpts??gid=5,mode=620??0 0
sysfs?????????????????? /sys????????????????????sysfs???defaults????????0 0
proc????????????????????/proc?????????????????? proc??? defaults????????0 0
LABEL=SWAP-sda3?????????swap????????????????????swap??? defaults????????0 0
LABEL=backup????????????/mnt/bak??????????????? ext3??? defaults????????1 2
轉(zhuǎn)載于:https://blog.51cto.com/cqfish/201672
總結(jié)
以上是生活随笔為你收集整理的Linux下的分区工具的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到鸟在笼子里是什么意思
- 下一篇: linux常见紧急情况处理