linux 新增硬盘分区并挂载
运行fdisk -l 查看计算机对应的硬盘信息
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders, total 41943040 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: 0x000eb08e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 499711 248832 83 Linux
/dev/vda2 501758 41940991 20719617 5 Extended
/dev/vda5 501760 41940991 20719616 8e Linux LVM
Disk /dev/vdb: 21.5 GB, 21474836480 bytes
3 heads, 34 sectors/track, 411206 cylinders, total 41943040 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: 0xaf2bf141
运行df -TH查看硬盘与持载关联关系
root@v-wdvwzli8s6e:~# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/ubuntu--vg-root ext4 19G 5.8G 13G 33% / none tmpfs 4.1k 0 4.1k 0% /sys/fs/cgroup udev devtmpfs 510M 13k 510M 1% /dev tmpfs tmpfs 105M 455k 104M 1% /run none tmpfs 5.3M 0 5.3M 0% /run/lock none tmpfs 522M 0 522M 0% /run/shm none tmpfs 105M 0 105M 0% /run/user /dev/vda1 ext2 247M 39M 196M 17% /boot
fdisk /dev/vdb 进入硬盘
n :创建分区 (h查看帮助)
mkfs -t ext3 -c /dev/sdb6 格式化硬盘
Disk /dev/vdb: 21.5 GB, 21474836480 bytes 3 heads, 34 sectors/track, 411206 cylinders, total 41943040 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: 0xaf2bf141 Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 5 Extended /dev/vdb5 4096 10244095 5120000 83 Linux /dev/vdb6 10246144 41943039 15848448 83 Linux
mount /dev/vdb5 /hyx/fffff/fff
root@v-wdvwzli8s6e:~# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/ubuntu--vg-root ext4 19G 5.8G 13G 33% / none tmpfs 4.1k 0 4.1k 0% /sys/fs/cgroup udev devtmpfs 510M 13k 510M 1% /dev tmpfs tmpfs 105M 455k 104M 1% /run none tmpfs 5.3M 0 5.3M 0% /run/lock none tmpfs 522M 0 522M 0% /run/shm none tmpfs 105M 0 105M 0% /run/user /dev/vda1 ext2 247M 39M 196M 17% /boot /dev/vdb6 ext3 16G 1.4G 14G 9% /hXXXXware/fast/db /dev/vdb5 ext3 5.1G 11M 4.8G 1% /hXXXXtware/fast/web
重启后自动挂载
root@v-wdvwzli8s6e:~# vim /etc/fstab
/dev/sdb5 /hyxSoftware/fast/web ext3 defaults 1 2 /dev/sdb6 /hyxSoftware/fast/db ext3 defaults 1 2
如果想每次系统重启都能自动挂载该分区可修改/etc/fstab文件,在最后加一段 /dev/sdb1 /www ext3 defaults 1 2 (格式说明:/dev/sdb1 代表哪个分区 ext3是该分区的格式 defaults 是挂载时所要设定的参数(只读,读写,启用quota等),输入defaults包括的参数有(rw、dev、exec、auto、nouser、async) ,1是使用dump是否要记录,0是不要。 2是开机时检查的顺序,是boot系统文件就为1,其他文件系统都为2,如不要检查就为0)
reboot 重启服务器
root@v-wdvwzli8s6e:~# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/ubuntu--vg-root ext4 19G 5.8G 13G 33% / none tmpfs 4.1k 0 4.1k 0% /sys/fs/cgroup udev devtmpfs 510M 13k 510M 1% /dev tmpfs tmpfs 105M 455k 104M 1% /run none tmpfs 5.3M 0 5.3M 0% /run/lock none tmpfs 522M 0 522M 0% /run/shm none tmpfs 105M 0 105M 0% /run/user /dev/vda1 ext2 247M 39M 196M 17% /boot /dev/vdb6 ext3 16G 1.4G 14G 9% /hyxxxxx/fast/db /dev/vdb5 ext3 5.1G 11M 4.8G 1% /hyxxxxxx/fast/web