查看分区容量
[root@Cnyunwei ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 250G 0 disk
├─sda1 8:1 0 512M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 65.5G 0 part /
尝试使用lv命令失败,非LVM分区
[root@Cnyunwei ~]# lvextend -l +100%FREE /dev/sda3
Path required for Logical Volume "sda3".
Please provide a volume group name
Run `lvextend --help' for more information.
查看磁盘详细信息
[root@Cnyunwei ~]# fdisk -l
Disk /dev/sda: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004b166
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 588 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 588 9138 68680704 83 Linux
重建磁盘起始扇区
[root@Cnyunwei ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sda: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004b166
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 588 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 588 9138 68680704 83 Linux
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
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): d
Partition number (1-4): 4
Warning: partition 4 has empty type
Command (m for help): 3
3: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
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): d
Partition number (1-4): 3
Command (m for help): d
Partition number (1-4): 3
Warning: partition 3 has empty type
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): u
Changing display/entry units to cylinders
Command (m for help): p
Disk /dev/sda: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004b166
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 588 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (588-32635, default 588): 588
Last cylinder, +cylinders or +size{K,M,G} (588-32635, default 32635): 32635
Command (m for help): wr
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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.
You have mail in /var/spool/mail/root
[root@Cnyunwei ~]# df -hl
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 65G 53G 8.6G 87% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 488M 45M 419M 10% /boot
[root@Cnyunwei ~]# init 6
刷新磁盘空间
[root@Cnyunwei ~]# resize2fs /dev/sda3
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old desc_blocks = 5, new_desc_blocks = 16
Performing an on-line resize of /dev/sda3 to 64355255 (4k) blocks.
The filesystem on /dev/sda3 is now 64355255 blocks long.
[root@Cnyunwei ~]# df -hl
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 242G 53G 177G 23% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 488M 45M 419M 10% /boot
评论区