Ubuntu 挂载新硬盘

0 查看目前挂载了那些硬盘,可以看到,只使用了sda 硬盘。

dacent@dacent:~$ df -lh
Filesystem                   Size  Used Avail Use% Mounted on
udev                          63G     0   63G   0% /dev
tmpfs                         13G  9.6M   13G   1% /run
/dev/mapper/dacent--vg-root  219G  2.0G  206G   1% /
tmpfs                         63G     0   63G   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                         63G     0   63G   0% /sys/fs/cgroup
/dev/sda1                    472M  107M  342M  24% /boot
tmpfs                         13G     0   13G   0% /run/user/1000
tmpfs                         13G     0   13G   0% /run/user/1001

1 发现新硬盘,找到新的硬盘。这里发现了sdb新硬盘。

sudo fdisk -l
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x1213cdba
 
Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1  *       2048    999423    997376   487M 83 Linux
/dev/sda2       1001470 468860927 467859458 223.1G  5 Extended
/dev/sda5       1001472 468860927 467859456 223.1G 8e Linux LVM
 
Partition 2 does not start on physical sector boundary.
 
 
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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

2 为sdb硬盘新建分区

linlf@dacent:~$ sudo fdisk /dev/sdb 
 
Welcome to fdisk (util-linux 2.27.1).
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.
Created a new DOS disklabel with disk identifier 0x6d19375b.
 
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 
 
Using default response p.
Partition number (1-4, default 1): 
First sector (2048-1953525167, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953525167, default 1953525167): 
 
Created a new partition 1 of type 'Linux' and of size 931.5 GiB.
 
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

3 查看新硬盘的新分区

sudo fdisk -l /dev/sdb
 
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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
Disklabel type: dos
Disk identifier: 0x6d19375b
 
Device     Boot Start        End    Sectors   Size Id Type
/dev/sdb1        2048 1953525167 1953523120 931.5G 83 Linux

4 把新分区的文件格式改成 ext4

linlf@dacent:~$ sudo mkfs.ext4 /dev/sdb1 
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 244190390 4k blocks and 61054976 inodes
Filesystem UUID: 938e6783-d5cb-4e38-98e2-e8e2b0918587
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848
 
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done  

4.2 在更改文件格式的时候,出现一些小插曲,是关于 /dev/sdb1 contains a ntfs file system :

linlf@ccrfox247:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
/dev/sdb1 contains a ntfs file system
无论如何也要继续? (y,n) y
Creating filesystem with 244190390 4k blocks and 61054976 inodes
Filesystem UUID: 92490692-374a-416d-8eaf-0e977964332b
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848
 
Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成 

5 查看新分区的文件类型与设备号


linlf@dacent:~$ sudo blkid /dev/sdb1 
/dev/sdb1: UUID="928e6783-d5cb-4e38-98e2-e8e2b0918587" TYPE="ext4" PARTUUID="6219375b-01"

6 有新分区之后,我们就可以着手挂载了,因为我希望我使用的存储空间大一些,所以我挂载在 /home 目录下,注意不能将同一个目录挂载在个不同的分区。

dacent@dacent:~$ sudo mkdir /new
dacent@dacent:~$ sudo mount /dev/sdb1 /new
dacent@dacent:~$ sudo cp -r /home/* /new
dacent@dacent:~$ 
dacent@dacent:~$ ls /new/  (查看是否复制成功)
dacent	linlf
dacent@dacent:~$ sudo umount /dev/sdb1
dacent@dacent:~$ sudo mount /dev/sdb1 /home (挂载成功)

7 最后,为了让新硬盘开机自动挂载,在 /etc/fstab 内增加一行 sudo vi /etc/fstab

UUID=928e6783-d5cb-4e38-98e2-e8e2b0918587   /home   ext4    defaults    0   2

8 重启以验证最后一步。

reboot

你可能感兴趣的:(环境,ubuntu,运维,数据库)