原来一个分区分得太小了(只有5G),等拷贝完数据才知道太小了。于是尝试了扩容的办法。以前对ext3干过这样的事情,看了ext3上的wiki介绍,得知做法和原来的ext2/ext3一样(看来兼容性还是不错)。下面是我的扩容过程
首先下载你要扩容的分区,这样当然是最保险的,如果你就是不想卸载,只要你别对其做写操作,也没有问题。
接下来就是用fdisk删除该分区,然后用你期望的大小重建该分区。这里要注意的是,分区的开始扇区一定要和删除前保持一致,否则文件系统就会遭到破坏。下面是我的实际操作过程
# fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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: 0x00067b51
Device Boot Start End Blocks Id System
/dev/sda1 * 63 29302559 14651248+ 83 Linux
/dev/sda2 29302784 39061503 4879360 83 Linux
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 2):
Using default value 2
First sector (29302560-125829119, default 29302560): 29302784
Last sector, +sectors or +size{K,M,G} (29302784-125829119, default 125829119): +20G
Command (m for help): p
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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: 0x00067b51
Device Boot Start End Blocks Id System
/dev/sda1 * 63 29302559 14651248+ 83 Linux
/dev/sda2 29302784 71245823 20971520 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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
而后执行下面的指令
# partprobe /dev/sda
# e2fsck -f /dev/sda2
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
data: 38934/305216 files (0.1% non-contiguous), 1140469/1219840 blocks
[root@wgzhao-nb wgzhao]# resize2fs /dev/sda2 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sda2 to 5242880 (4k) blocks.
The filesystem on /dev/sda2 is now 5242880 blocks long.
我们再挂载上来,得到的就是我期望的大小了(20G)
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 14G 6.5G 7.2G 48% /
tmpfs 1.4G 296K 1.4G 1% /dev/shm
/dev/sda2 20G 4.3G 16G 22% /data