官术网_书友最值得收藏!

Linux procedure for formatting and mounting a persistent disk

Newly created persistent disks do not have any filesystems on them. We must format them with the desired filesystem and the number of partitions we need. Here, we will format it with a single partition and ext4 filesystem. To do so:

  1. Go to the VM instances page and access your instance through the browser using SSH.
  2. One you are prompted to the Terminal, use the lsblk command to list the attached disks to your instance:
sudo lsblk  
  1. To format disks, use the make filesystem (mkfs) command. You can also make the runtime and formatting faster by means of optional arguments to disable lazy initialization:
sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0, lazy_journal_init=0, discard /dev/sda 
  1. Now, to mount the formatted disk, create a directory that will serve as your mounting point:
sudo mkdir /mnt/my-mounting-dir  
  1. Use the mount command and provide the disk and mounting point as arguments. Also make sure that the discard option is enabled:
sudo mount -o discard, defaults /dev/sda /mnt/my-mounting-dir  
  1. You can also configure read and write permissions for users. We will provide write access to all users:
sudo chmod a+w /mnt/my-mounting-dir  

Again, if you are attaching a persistent disk to your VM, the disk and the VM have to be in the same zone. Your VM instance and the persistent disk cannot be in different zones.

主站蜘蛛池模板: 青川县| 汉中市| 绥德县| 襄垣县| 新源县| 桂东县| 江阴市| 鄯善县| 辰溪县| 额济纳旗| 奉节县| 瑞金市| 吉木萨尔县| 九江市| 贡山| 胶南市| 安岳县| 紫阳县| 友谊县| 诸城市| 青川县| 普定县| 萨嘎县| 深州市| 夏河县| 台东市| 明星| 昌黎县| 本溪| 固阳县| 遵化市| 广安市| 靖边县| 汉川市| 青田县| 淳安县| 鄂尔多斯市| 静宁县| 柳州市| 罗城| 三台县|