清风徐来
Michael's Blog
Somagu NAT 小鸡的挂载过程

Somagu 提供了免费的 kvm 技术的 vps(免费到2017年9月底),虽然是 NAT 的(共享公网 IP),但是线路不错还是可玩的。 SomaguVps.png Somagu 小鸡根据你选择的 OS 模板,默认只有2.2G 或是8G 的硬盘空间。但是它提供了20G 的 Disk,但是需要我们自己去挂载。官网的说明

If you created a VPS based on OS template, your extra disk space is at /dev/vdb device. Please mount, format and use it.

好吧,下面记录一下挂载过程,Linux 挂载基本都是这个套路了。

# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        222M     0  222M   0% /dev
tmpfs           244M   24K  244M   1% /dev/shm
tmpfs           244M  8.3M  236M   4% /run
tmpfs           244M     0  244M   0% /sys/fs/cgroup
/dev/vda1       8.0G  3.7G  4.4G  46% /
tmpfs            49M     0   49M   0% /run/user/1000

看到了,只有8G。

# fdisk -l

Disk /dev/vda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000b2270

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16777215     8387584   83  Linux

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 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 /dev/vdc: 0 MB, 374784 bytes, 732 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

有/dev/vda, /dev/vdb, /dev/vdc;其中/dev/vdb有21.5G,但是没有分区

# 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 0xb548910e.

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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

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

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

按照界面的提示,依次输入“n”(新建分区)、“p”(新建扩展分区)、“1”(使用第1个主分区),两次回车(使用默认配置),输入“wq”(保存分区表),回车开始分区。

# fdisk -l

Disk /dev/vda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000b2270

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16777215     8387584   83  Linux

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 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 label type: dos
Disk identifier: 0xb548910e

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048    41943039    20970496   83  Linux

Disk /dev/vdc: 0 MB, 374784 bytes, 732 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

再次查看,/dev/vdb已经分区了,vdb1已经创建完成。

# mkfs.ext4 /dev/vdb1
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
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 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

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

完成格式化

# mkdir /data
# mount /dev/vdb1 /data
# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        222M     0  222M   0% /dev
tmpfs           244M   24K  244M   1% /dev/shm
tmpfs           244M  8.3M  236M   4% /run
tmpfs           244M     0  244M   0% /sys/fs/cgroup
/dev/vda1       8.0G  3.7G  4.4G  46% /
tmpfs            49M     0   49M   0% /run/user/1000
/dev/vdb1        20G   45M   19G   1% /data

新建/data 文件夹; 挂载/dev/vdb1 到/data; 查看结果,成功挂载了。

重启后挂载回消失,所以最好能够自动挂载。先创建 /etc/fstab 文件的备份,再编辑

# cp /etc/fstab /etc/fstab.backup
# vi /etc/fstab

输入:device_name mount_point file_system_type fs_mntops fs_freq fs_passno

本例:

/dev/vdb1 /data ext4 defaults,nofail 0 1

# mount -a

如果运行通过则说明文件正常,刚刚创建的文件系统会在下次启动时自动安装. end.


最后修改于 2017-09-02