侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

ECS:硬盘分区及挂载操作步骤

2023-11-29 星期三 / 0 评论 / 0 点赞 / 52 阅读 / 9787 字

云服务器环境:CentOS 7 客户端环境:windows 7 远程连接方式:运行 Xshell,输入命令 ssh username@ip 然后输入密码 查看磁盘空间情况 [root@iZbp1j6o

云服务器环境:CentOS 7

客户端环境:windows 7

远程连接方式:运行 Xshell,输入命令 ssh username@ip 然后输入密码

查看磁盘空间情况

[root@iZbp1j6oiamq7t2otpryarZ ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/vda1        40G  1.6G   36G   5% /devtmpfs        3.9G     0  3.9G   0% /devtmpfs           3.9G     0  3.9G   0% /dev/shmtmpfs           3.9G  372K  3.9G   1% /runtmpfs           3.9G     0  3.9G   0% /sys/fs/cgrouptmpfs           783M     0  783M   0% /run/user/0

查看未挂载的硬盘

这里可以看到 Disk /dev/vdb: 107.4 GB 的磁盘是未挂载的

[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -lDisk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0008de3e   Device Boot      Start         End      Blocks   Id  System/dev/vda1   *        2048    83884031    41940992   83  LinuxDisk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes

创建分区

这里我将107G的磁盘分为两个区,各50G ,

First sector (2048-209715199, default 2048): 104800000 

红色的部分是我的分区大小分割点

[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk /dev/vdbWelcome 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 tableBuilding a new DOS disklabel with disk identifier 0x0dbdad0c.Command (m for help): nPartition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-209715199, default 2048): 104800000    Last sector, +sectors or +size{K,M,G} (104800000-209715199, default 209715199): Using default value 209715199Partition 1 of type Linux and of size 50 GiB is setCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.

格式化

这里我格式化为xfs ,

# mkfs.ext3 /dev/vdb1
# mkfs.ext4 /dev/vdb1
# mkfs.xfs -f /dev/vdb1

.

Ext3 目前所支持的最大 16TB 文件系统,最大 2TB 文件;
Ext4 目前所支持 1EB(1,048,576TB, 1EB=1024PB, 1PB=1024TB)的文件系统,以及 16TB 的文件。对一般的台式机和服务器而言,这可能并不重要,但对于大型磁盘阵列的用户而言,这就非常重要了。
XFS 是一个64位文件系统,最大支持8EB减1字节的单个文件系统,实际部署时取决于宿主操作系统的最大块限制。对于一个32位Linux系统,文件和文件系统的大小会被限制在16TB。

.
[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -lDisk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0008de3e   Device Boot      Start         End      Blocks   Id  System/dev/vda1   *        2048    83884031    41940992   83  LinuxDisk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0dbdad0c   Device Boot      Start         End      Blocks   Id  System/dev/vdb1            2048   104859647    52428800   83  Linux/dev/vdb2       104859648   209715199    52427776   83  Linux[root@iZbp1j6oiamq7t2otpryarZ ~]# mkfs.xfs -f /dev/vdb1meta-data=/dev/vdb1              isize=512    agcount=4, agsize=3278600 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=1        finobt=0, sparse=0data     =                       bsize=4096   blocks=13114400, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal log           bsize=4096   blocks=6403, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0[root@iZbp1j6oiamq7t2otpryarZ ~]# mkfs.xfs -f /dev/vdb2meta-data=/dev/vdb2              isize=512    agcount=4, agsize=3274936 blks         =                       sectsz=512   attr=2, projid32bit=1         =                       crc=1        finobt=0, sparse=0data     =                       bsize=4096   blocks=13099744, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal log           bsize=4096   blocks=6396, version=2         =                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0

挂载分区

这里我需要创建/app 和 /data 两个目录,分别存放应用程序、mysql数据库文件。

[root@iZbp1j6oiamq7t2otpryarZ ~]# mkdir /app[root@iZbp1j6oiamq7t2otpryarZ ~]# mkdir /data[root@iZbp1j6oiamq7t2otpryarZ /]# ls -ltotal 68drwxr-xr-x    2 root root  4096 Nov  1 13:03 applrwxrwxrwx.   1 root root     7 Aug 18 11:51 bin -> usr/bindr-xr-xr-x.   4 root root  4096 Oct 31 11:26 bootdrwxr-xr-x    2 root root  4096 Nov  1 13:03 datadrwxr-xr-x   20 root root  3060 Oct 31 11:26 devdrwxr-xr-x.  82 root root  4096 Oct 31 11:26 etcdrwxr-xr-x.   2 root root  4096 Nov  5  2016 homelrwxrwxrwx.   1 root root     7 Aug 18 11:51 lib -> usr/liblrwxrwxrwx.   1 root root     9 Aug 18 11:51 lib64 -> usr/lib64drwx------.   2 root root 16384 Aug 18 11:51 lost+founddrwxr-xr-x.   2 root root  4096 Nov  5  2016 mediadrwxr-xr-x.   2 root root  4096 Nov  5  2016 mntdrwxr-xr-x.   2 root root  4096 Nov  5  2016 optdr-xr-xr-x  102 root root     0 Oct 31 11:26 procdr-xr-x---.   5 root root  4096 Oct 31 11:26 rootdrwxr-xr-x   22 root root   620 Oct 31 11:26 runlrwxrwxrwx.   1 root root     8 Aug 18 11:51 sbin -> usr/sbindrwxr-xr-x.   2 root root  4096 Nov  5  2016 srvdr-xr-xr-x   13 root root     0 Oct 31 19:26 sysdrwxrwxrwt.   8 root root  4096 Nov  1 03:50 tmpdrwxr-xr-x.  13 root root  4096 Aug 18 11:51 usrdrwxr-xr-x.  19 root root  4096 Oct 31 19:26 var[root@iZbp1j6oiamq7t2otpryarZ ~]# mount /dev/vdb2 /data[root@iZbp1j6oiamq7t2otpryarZ ~]# mount /dev/vdb1 /app[root@iZbp1j6oiamq7t2otpryarZ ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/vda1        40G  1.6G   36G   5% /devtmpfs        3.9G     0  3.9G   0% /devtmpfs           3.9G     0  3.9G   0% /dev/shmtmpfs           3.9G  348K  3.9G   1% /runtmpfs           3.9G     0  3.9G   0% /sys/fs/cgrouptmpfs           783M     0  783M   0% /run/user/0/dev/vdb2        50G   33M   50G   1% /data/dev/vdb1        51G   33M   50G   1% /app[root@iZbp1j6oiamq7t2otpryarZ ~]# 

设置开机自动挂载

增加内容:

/dev/vdb1    /app    xfs    defaults        0 0
/dev/vdb2   /data    xfs    defaults        0 0

[root@iZbp1j6oiamq7t2otpryarZ ~]# vi /etc/fstab[root@iZbp1j6oiamq7t2otpryarZ ~]# cat /etc/fstab ## /etc/fstab# Created by anaconda on Fri Aug 18 03:51:14 2017## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=59d9ca7b-4f39-4c0c-9334-c56c182076b5 /                       ext4    defaults        1 1/dev/vdb1	/app	xfs    defaults        0 0/dev/vdb2   /data   xfs    defaults        0 0

卸载分区

[root@iZbp1j6oiamq7t2otpryarZ ~]# umount /dev/vdb2 /data[root@iZbp1j6oiamq7t2otpryarZ ~]# umount /dev/vdb1 /app[root@iZbp1j6oiamq7t2otpryarZ ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/vda1        40G  1.6G   36G   5% /devtmpfs        3.9G     0  3.9G   0% /devtmpfs           3.9G     0  3.9G   0% /dev/shmtmpfs           3.9G  348K  3.9G   1% /runtmpfs           3.9G     0  3.9G   0% /sys/fs/cgrouptmpfs           783M     0  783M   0% /run/user/0[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -lDisk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0008de3e   Device Boot      Start         End      Blocks   Id  System/dev/vda1   *        2048    83884031    41940992   83  LinuxDisk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0dbdad0c   Device Boot      Start         End      Blocks   Id  System/dev/vdb1            2048   104859647    52428800   83  Linux/dev/vdb2       104859648   209715199    52427776   83  Linux

 

广告 广告

评论区