


Formatting the Linux system partition of the Alibaba Cloud host and mounting the data disk
In addition to the free system disk in Alibaba Cloud, the second cloud disk purchased is not automatically mounted by default and needs to be manually configured and mounted.
Use [Management Terminal] or remote connection tool, enter the user name root and password to log in to the Linux system.
1. Run the fdisk -l command to view the data disk. Before partitioning and formatting the data disk, you cannot see the data disk using the "df -h" command. You can use the "fdisk -l" command to view it.
After executing the command, if /dev/vdb does not exist, it means there is no data disk. Confirm whether the data disk is mounted.
2. Execute the following commands in sequence to create a single-partition data disk:
(1) Run fdisk -u /dev/vdb: partition data disk.
(2) Enter p: Check the partition status of the data disk. In this example, the data disk has no partitions.
(3) Enter n: Create a new partition.
(4) Enter p: Select the partition type as the primary partition.
Description In this example, a single-partition data disk is created, so only the primary partition needs to be created. If you want to create more than four partitions, you should create at least one extended partition, i.e. select e (extended).
(5) Enter the partition number and press Enter. In this example, only one partition is created, enter 1.
(6) Enter the first available sector number: press Enter to adopt the default value of 2048.
(7) Enter the last sector number: This example only creates one partition, press Enter to adopt the default value.
(8) Enter p: View the planned partitioning of the data disk.
(9) Enter w: start partitioning and exit after partitioning.
[root@ecshost~ ]# fdisk -u /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 0x3e60020e. Command (m for help): p 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: 0x3e60020e Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 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): p 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: 0x3e60020e Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
3. Run the command fdisk -lu /dev/vdb to view the new partition.
If the following information appears, it means that the new partition /dev/vdb1 is created successfully.
[root@ecshost~ ]# fdisk -lu /dev/vdb 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: 0x3e60020e Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux
4. Run the command mkfs.ext4 /dev/vdb1 to create a file system on the new partition.
In this example, create an ext4 file system. You can also choose to create other file systems according to your own needs. For example: if you need to share files between Linux, Windows and Mac systems, you can use mkfs.vfat to create a VFAT file system.
Note: The time required to create a file system depends on the size of the data disk.
[root@ecshost~ ]# 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
5. (Recommended) Run the command cp /etc/fstab /etc/fstab.bak to back up the etc/fstab file.
6. Run the command echo /dev/vdb1 /data0 ext4 defaults 0 0 >> /etc/fstab to write new partition information to /etc/fstab.
Note: The Ubuntu 12.04 system does not support barriers. You need to run the command echo '/dev/vdb1 /data0 ext4 barrier=0 0 0' >> /etc/fstab.
If you want to mount the data disk to a folder separately, for example, to store web pages alone, replace /data0 in the command with the required mount point path.
7. Run the command cat /etc/fstab to view the new partition information in /etc/fstab.
[root@ecshost~ ]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Wed Dec 12 07:53:08 2018 # # 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=d67c3b17-255b-4687-be04-f29190d37396 / ext4 defaults 1 1 /dev/vdb1 /mnt ext4 defaults 0 0
8. Run the command mount /dev/vdb1 /data0 to mount the file system.
9. Run the command df -h to check the current disk space and usage.
The information about the new file system appears, indicating that the mounting is successful.
<div><br class="Apple-interchange-newline">[root@ecshost~ ]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 1.6G 36G 5% / devtmpfs 234M 0 234M 0% /dev tmpfs 244M 0 244M 0% /dev/shm tmpfs 244M 484K 244M 1% /run tmpfs 244M 0 244M 0% /sys/fs/cgroup tmpfs 49M 0 49M 0% /run/user/0 /dev/vdb1 20G 45M 19G 1% /mnt</div> 12345678910 [root@ecshost~ ]# df -h Filesystem Size Used Avail Use% Mounted on/dev/vda1 40G 1.6G 36G 5% /devtmpfs 234M 0 234M 0% /devtmpfs 244M 0 244M 0% /dev/shmtmpfs 244M 484K 244M 1% /runtmpfs 244M 0 244M 0% /sys/fs/cgrouptmpfs 49M 0 49M 0% /run/user/0/dev/vdb1 20G 45M 19G 1% /mnt
10. Finally reboot, restart the server.
Recommended: "linux video tutorial"
The above is the detailed content of Formatting the Linux system partition of the Alibaba Cloud host and mounting the data disk. For more information, please follow other related articles on the PHP Chinese website!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools