How to partition a disk, set its file system type & mount it

简介:
  1. 缘起同事在调整VolGroup-lv_root与VolGroup-lv_home分区大小之时,系统还未执行完直接重启了,导致报错如下
    Screenshot_from_2018_07_13_17_16_35
  1. parted -l查看后发现,/dev/mapper/VolGroup-lv_home的Partition Table类型为msdos,需修改为loop
    Screenshot_from_2018_07_13_17_18_09
  1. 解决方法
1) To know all the disks attached to VPS/Server type

 # parted --list

 It will show you all the disk along with the unpartitioned disk. Let, we attached a new disk "/dev/xvdb" to server. It will show "unrecognised disk label" message on "parted --list".

 ----
 root@server [~] parted /dev/xvdb
 GNU Parted 1.8.1
 Using /dev/xvdb
 Welcome to GNU Parted! Type 'help' to view a list of commands.
 (parted) print free
 Error: Unable to open /dev/xvdb - unrecognised disk label.
 ----

 2) Execute the following command to edit disk "/dev/xvdb":

 # parted /dev/xvdb

 3) Type "mklabel msdos"

 It creates a new disk label of type "msdos". The new disk label will have no partitions. This command won't technically destroy your data, but it will make it will make it basically unusable.

 ----
 (parted) mklabel msdos
 ----

 4) Type "print free" to know the partition details.

 ----
 (parted) print free

 Model: Xen Virtual Block Device (xvd)
 Disk /dev/xvdb: 53.7GB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos

 Number Start End Size Type File system Flags
 0.00kB 53.7GB 53.7GB Free Space

 (parted)
 ----

 5) Type "mkpart primary 0.00kB 53.7GB" (let the total size is 53.7GB)

 ----
 (parted) mkpart primary 0.00kB 53.7GB
 ----

 6) Again type "print free" to know the partition details.

 ----
 (parted) print free

 Model: Xen Virtual Block Device (xvd)
 Disk /dev/xvdb: 53.7GB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos

 Number Start End Size Type File system Flags
 1 0.51kB 53.7GB 53.7GB primary

 (parted)
 ----

 7) type "quit" to exit the parted utility.

 ----
 (parted) quit
 Information: Don't forget to update /etc/fstab, if necessary.

 root@server [~]#
 ----

 8) Execute the following command:

 # parted --list

 This time it will show the new disk too. Now we have to set the file system type on the disk and mount it.

 ==========
 root@server [~]# parted --list
 Error: Unable to open /dev/md0 - unrecognised disk label.


 Model: Unknown (unknown)
 Disk /dev/sda2: 1074MB
 Sector size (logical/physical): 512B/512B
 Partition Table: loop

 Number Start End Size File system Flags
 1 0.00kB 1074MB 1074MB linux-sw ap


 Model: Unknown (unknown)
 Disk /dev/sda1: 73.4GB
 Sector size (logical/physical): 512B/512B
 Partition Table: loop

 Number Start End Size File system Flags
 1 0.00kB 73.4GB 73.4GB ext3


 Model: Unknown (unknown)
 Disk /dev/xvdb: 53.6GB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos

 Number Start End Size File system Flags
 1 0.00kB 53.6GB 53.6GB ext3
 ==========

 8) Since the partition is not formated so we cannot mount it without formatting. To format the new disk use "mkfs.ext3 /dev/xvdb1". It may take some time to process.

 ====================
 root@server [~]# mkfs.ext4 /dev/xvdb
 mke2fs 1.39 (29-May-2006)
 Filesystem label=
 OS type: Linux
 Block size=4096 (log=2)
 Fragment size=4096 (log=2)
 6553600 inodes, 13107199 blocks
 655359 blocks (5.00%) reserved for the super user
 First data block=0
 Maximum filesystem b locks=4294967296
 400 block groups
 32768 blocks per group, 32768 fragments per group
 16384 inodes per group
 Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424

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

 This filesystem will be automatically checked every 38 mounts or
 180 days, whichever comes first. Use tune2fs -c or -i to override.
 ====================

 9) Take a backup of file "/etc/fstab" and then open it using "vi" editor and mount it

 ------
 root@server [~]# cp -pv /etc/fstab /etc/fstab2
 `/etc/fstab' -> `/etc/fstab2'
 ------

 We will add the following line in "/etc/fstab". Here we are mounting the partition at "/backup" directory.

------
 /dev/xvdb1   /backup   ext4   defaults   0   0
------

 10) Use the following command to mount it.

 ------
 root@server [~]# mount /backup
 ------

Thank you.

原文连接
How to partition a disk, set its file system type & mount it

目录
相关文章
|
5月前
|
Linux iOS开发 MacOS
pnpm全局安装报错:Run “pnpm setup“ to create it automatically, or set the global-bin-dir setting, or the PN
pnpm全局安装报错:Run “pnpm setup“ to create it automatically, or set the global-bin-dir setting, or the PN
1767 0
|
2月前
husky——The '.husky/pre-commit' hook was ignored because it's not set as executable
husky——The '.husky/pre-commit' hook was ignored because it's not set as executable
56 1
|
2月前
|
CDN
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
46 0
Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension.
Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension.
|
JavaScript 前端开发
.bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your op..
.bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your op..
202 0
|
应用服务中间件 Linux BI
Tomcat部署iframe出现Refused to display ‘url‘ in a frame because it set ‘X-Frame-Options‘ to ‘deny‘无法访问问题
Tomcat部署iframe出现Refused to display ‘url‘ in a frame because it set ‘X-Frame-Options‘ to ‘deny‘无法访问问题
695 0
Tomcat部署iframe出现Refused to display ‘url‘ in a frame because it set ‘X-Frame-Options‘ to ‘deny‘无法访问问题
|
Java 应用服务中间件 Python
Refused to display 'xxx' in a frame ,because it set 'X-Frame-Options' to 'deny'.
我本是在DJANGO页面的iframe里嵌入springboot的页面。 当报了这个错误之后,我花了时间在nginx和django上, 后来才改变解决思路,从springboot出发,解决问题。
5818 0
|
10天前
|
存储 JavaScript 前端开发
Set、Map、WeakSet 和 WeakMap 的区别
在 JavaScript 中,Set 和 Map 用于存储唯一值和键值对,支持多种操作方法,如添加、删除和检查元素。WeakSet 和 WeakMap 则存储弱引用的对象,有助于防止内存泄漏,适合特定场景使用。