场景:
在初步完成学生机房虚拟化设计后所映现出来的问题。由于磁盘的分区过大,导致在备份还原系统时时间会很长,且存在fat32分区,导致Clonezilla速度明显减慢。
具体描述:
现在我需要做的是,删除两个分区,然后创建一个较小分区。注意,此处所指分区均不是系统分区,而是本人在安装系统时自行创建的。
删除分区:
shenzhi@sz0850:~$ sudo fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 250.1 GB, 250058268160 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488395055 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8d4bc3f7
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 585727 291840 83 Linux
/dev/sda2 162701310 488392064 162845377+ f W95 Ext'd (LBA)
/dev/sda3 585728 156835839 78125056 83 Linux
/dev/sda4 156835840 162695167 2929664 82 Linux swap / Solaris
/dev/sda5 419473278 488392064 34459393+ b W95 FAT32
/dev/sda6 162701312 419471359 128385024 83 Linux
Partition table entries are not in disk order
此处需要删除的就是/dev/sda5、/dev/sda6两个分区,记得删除后还要保存才是。
Command (m for help): d
Partition number (1-6): 6
Command (m for help): d
Partition number (1-5): 5
创建分区:
Command (m for help): n
First sector (162703358-488392064, default 162703358):
Using default value 162703358
Last sector, +sectors or +size{K,M,G} (162703358-488392064, default 488392064):+25G
分区结果:
Command (m for help): p
Disk /dev/sda: 250.1 GB, 250058268160 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488395055 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8d4bc3f7
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 585727 291840 83 Linux
/dev/sda2 162701310 488392064 162845377+ f W95 Ext'd (LBA)
/dev/sda3 585728 156835839 78125056 83 Linux
/dev/sda4 156835840 162695167 2929664 82 Linux swap / Solaris
/dev/sda5 162703358 215132157 26214400 83 Linux
Partition table entries are not in disk order
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
一定要记得在确定无误后保存对磁盘的修改,w的意思就是写入对磁盘的修改
磁盘格式化:
此处只是一个例子,而非上述新建的25G磁盘
shenzhi@sz0850:~$ sudo mkfs -t ext4 /dev/sda5
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2154496 inodes, 8614848 blocks
430742 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
263 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
查看新建分区的uuid:
shenzhi@sz0850:~$ ls -l /dev/disk/by-uuid/
从这里可以看出,UUID其实是对硬盘物理分区的一个软链接
total 0
lrwxrwxrwx 1 root root 10 2012-01-06 15:52 2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 -> ../../sda1
lrwxrwxrwx 1 root root 10 2012-01-06 15:52 4afba6a9-1e8b-4412-bc69-a9c6b119b015 -> ../../sda4
lrwxrwxrwx 1 root root 10 2012-01-06 15:52 b318e04d-999c-4f93-b1e4-0b43283d46f8 -> ../../sda3
lrwxrwxrwx 1 root root 10 2012-01-06 15:52 f5b0f47a-a0b9-48d7-8cd0-943c33fe579e -> ../../sda5
还有一种方法也可以查看UUID:
- [shenzhi@shenzhi ~]$ blkid
- /dev/sda1: LABEL="SYSTEM" UUID="06D07950D07946C9" TYPE="ntfs"
- /dev/sda2: LABEL="kk" UUID="0009E46F0007E3C7" TYPE="ntfs"
- /dev/sda5: LABEL="sorce" UUID="C220072F20072A4D" TYPE="ntfs"
- /dev/sda6: UUID="d5a7269c-196a-4c0a-890b-ba00f33d695b" TYPE="ext4"
- /dev/sda9: UUID="540b21b6-3379-4a85-b670-9324a985798e" TYPE="swap"
- [shenzhi@shenzhi ~]$
修改挂载:
注意观察加粗部分
shenzhi@sz0850:~$ sudo vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda3 during installation
UUID=b318e04d-999c-4f93-b1e4-0b43283d46f8 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 /boot ext4 defaults 0 2
# /vmos was on /dev/sda6 during installation
UUID=545352eb-e087-4d75-8206-d8c5e275b4bb /vmos ext4 defaults 0 2
# swap was on /dev/sda4 during installation
UUID=4afba6a9-1e8b-4412-bc69-a9c6b119b015 none swap sw
0 0
修改后:
shenzhi@sz0850:~$ sudo vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda3 during installation
UUID=b318e04d-999c-4f93-b1e4-0b43283d46f8 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=2f3c44ac-7e62-4d78-af27-cb6a2a2c50f4 /boot ext4 defaults 0 2
# /vmos was on /dev/sda5 during installation
UUID=f5b0f47a-a0b9-48d7-8cd0-943c33fe579e /vmos ext4 defaults 0 2
# swap was on /dev/sda4 during installation
UUID=4afba6a9-1e8b-4412-bc69-a9c6b119b015 none swap sw 0 0
至此,关于磁盘的调整结束。
本文转自tiancong 51CTO博客,原文链接:http://blog.51cto.com/tiancong/758943