公司ubuntu server服务器因业务数据量上升,df下磁盘,使用量达97%
root@xinju:/home/xinju# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00022eb9
设备 启动 起点 终点 块数 Id 系统
/dev/sda1 * 2048 39063551 19530752 83 Linux
/dev/sda2 39065598 208594943 84764673 5 扩展
/dev/sda5 39065600 196093951 78514176 83 Linux
/dev/sda6 196096000 208594943 6249472 82 Linux 交换 / Solaris
root@xinju:/home/xinju# poweroff
xinju@xinju:~$ df
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda1 19222656 7296252 10949868 40% /
udev 3047540 4 3047536 1% /dev
tmpfs 1222724 232 1222492 1% /run
none 5120 0 5120 0% /run/lock
none 3056800 0 3056800 0% /run/shm
/dev/sda5 77277876 73350980 1188 100% /home
xinju@xinju:~$ ls
准备把磁盘扩容下。
1,vsphere给虚拟机添加100G新硬盘;
2, 查看硬盘情况,获取新硬盘逻辑分区名是/dev/sdb,
sudo lshw -C disk
sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xee55da6f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
命令(输入 m 获取帮助): m
命令操作
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)
3,输入n,添加一个新分分区;输入e,作为扩展分区[extend],选择完后,会出现原始界面,继续选择n,然后就可以选择把之前分好的Extend Partion 分区成Logical Partion.这样的分区才可以格式化使用。分完后,通过菜单选择P, 可以print the partition table.看看我们是否分区的合理。然后,选择w保存就可以了。
4,格式化分区
root@xinju:/home/xinju# mkfs -t ext4 /dev/sdb
mke2fs 1.42 (29-Nov-2011)
/dev/sdb is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
800 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, 11239424, 20480000, 23887872
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
5,home目录添加新目录,供新磁盘挂载,
root@xinju:/home# mkdir mount
root@xinju:/home# mount /dev/sdb /home/mount
结束。后续注意新的挂载目录权限分配。