linux 新硬盘挂载到 /home 等指定目录下

1、新增磁盘的设备文件名为 /dev/vdb 大小为300G

 查看硬盘列表 可以看到新的磁盘设备  /dev/vdb 的信息。

# fdisk -l

2、给磁盘设备 进行分区

我这里将磁盘分为一个分区,类型为扩展分区。

[root@host]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd1945641.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-629145599, default 2048): 629145599
Partition 1 of type Extended and of size 512 B is set

Command (m for help): p

Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 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 label type: dos
Disk identifier: 0xd1945641

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1       629145599   629145599           0+   5  Extended

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3、分区之后、磁盘不能使用,需要先进行格式化

[root@host]# mkfs -t ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78643200 blocks
3932160 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2227175424
2400 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, 71663616

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     

4、这样磁盘就可以使用了,将格式化好的盘进行挂载

cd /mnt/
mkdir home
mount /dev/vdb /mnt/home 挂载到/mnt/home
df -h 查看
cp -a /home/ /mnt/home/ 把home下的东西拷到挂载的目录下,备份
rm -rf /home/ 把home下的东西删干净
umount /dev/vdb 卸载硬盘
df -h 查看

5、设置开机挂载

vim /etc/fstab
末尾增加一行
/dev/vdb /home ext4 defaults 0 0
保存退出
有时需要使用 blkid 命令查看设备的UUID号,即将上面的/dev/vdb1 替换成/dev/vdb1的UUID号
df -h 查看 /home是否被挂载

6、挂载未挂载磁盘

mount -a 挂载/etc/fstab 中未挂载的分区
df -h 查看

 

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值