Dual system (ubuntu+win) partition space allocation and file communication

preface

Didn't I change from the dual system to wsl2+mabaxterm before, but the linux subsystem under windows still has a lot of restrictions when doing many activities. It's not just a graphical interface problem, this x11 server using mobaxterm can basically solve it; the main reason is that wsl's restrictions on some versions of the software package are really confusing. So use dual systems.

This time I installed the dual system, I learned the previous lessons, and understood and sorted out many things that were vague when I installed the dual system before. Hope to help you.

Since the time I wrote this tweet was actually more than half a month after I installed the dual system, there are no pictures. However, I will focus on sharing some content that is of general concern.

common problem

How is the system partition allocated?

This must be one of the problems that bothers everyone, because the information on the Internet is different, and there are few specific explanations, and some partition schemes make people feel very distressed about memory, so that they doubt whether this allocation method is really appropriate.

overall process

When installing Ubuntu dual system on a computer with Windows system already installed, you can follow the steps below to allocate space to the Ubuntu system:

1. Open the Windows system and open the Disk Management (Disk Management).

2. In the disk manager, find the disk partition where the Ubuntu system is currently installed. You can judge it based on information such as disk size and file system type.

3. Right-click on the disk partition and select Shrink Volume.

4. In the pop-up dialog box, enter the size of the space to be allocated to the Ubuntu system, in MB. Note that a certain amount of space needs to be reserved here for the installation and operation of the Ubuntu system. It is recommended to allocate at least 20GB of space.

5. Click the "Shrink" button and wait for Disk Manager to finish allocating space.

6. Open the installer of the Ubuntu system, and select "Something Else" on the partition selection interface.

7. In the list of partitions, find the space just allocated to the Ubuntu system, select the space, and click the "New Partition" button.

8. In the dialog box that pops up, select parameters such as the size of the partition and the type of the file system. It is recommended to select the ext4 file system.

9. Click the "OK" button to complete the partition creation.

10. In the partition list, find the newly created partition, select it, and mount it to the "/" root directory.

11. Click the "Install" button and wait for the Ubuntu system installer to complete the installation process.

The above are the steps to allocate space for the Ubuntu system when installing the Ubuntu dual system on a computer that has already installed the Windows system. It should be noted that before performing any disk partition operations, it is recommended to back up important data.

Is it necessary to divide the size of each partition of Ubuntu (such as root directory, root, home) separately?

When partitioning the Ubuntu system, it is usually necessary to divide the root directory (/), swap partition and /home partition into three partitions. in:

1. The root directory (/) partition contains all the files and folders of the Ubuntu system, and enough space should be allocated to ensure the normal operation of the system. It is recommended to set the size of the root directory partition to more than 20GB so that the Ubuntu system can be installed and run normally.

2. The swap partition is used to store unused memory data, which can help improve system performance and stability. It is recommended to set the size of the swap partition to 1.5 times the memory capacity. For example, if the computer has 8GB of memory, you can set the size of the swap partition to 12GB.

3. The /home partition is used to store user files and setting information, so if there are multiple users in the Ubuntu system, or a large amount of files and data need to be stored in the Ubuntu system, it is recommended to divide the /home partition separately. It is recommended to set the size of the /home partition to the total size of the files and data to be stored plus a certain reserved space.

In general, only allocating space to the root directory partition may cause some problems. For example, if the computer has insufficient disk space, it may affect the normal operation of the system and data storage. Therefore, it is recommended to reasonably divide the size of the root directory, swap and /home partition according to your actual needs.

If the physical memory reaches 16G, does swap still need to be partitioned? It hurts to divide 24G

If the physical memory has reached 16GB, there is no need to divide the swap partition for the Ubuntu system. Because in most cases, the swap partition is mainly used to expand the capacity of physical memory so that the system can better manage memory, but on computers with more than 16GB of physical memory, the swap partition may be rarely used, and more than 16GB of memory is enough to support the operation of most applications.

But if the computer still has the problem of high memory usage, or needs to run memory-intensive tasks such as large applications or virtual machines, you can divide the Ubuntu system into a swap partition. It is not necessary to divide the swap partition too large, which will waste disk space; but do not set it too small to avoid insufficient memory.

The home directory is the directory below the root directory, why can it be divided into separate partitions?

The /home directory is a subdirectory in the root directory of the Ubuntu system, which is used to store the user's personal files and setting information. Although the /home directory is under the root directory, it can be partitioned separately, which has the following advantages:

1. Data isolation: Divide the /home directory into a separate partition, which can store user data and system files separately, thereby increasing data isolation. In this way, when reinstalling the system or repartitioning, the user's data will not be affected and can remain intact.

2. System maintenance: Dividing the /home directory into a separate partition can make system maintenance more convenient. For example, if you need to upgrade the system or change the partition size, you only need to unmount the /home partition without affecting other system files.

3. Backup and recovery: Divide the /home directory into a separate partition, which can easily back up and restore user data. For example, if you need to back up user data, you only need to back up the /home partition instead of the entire root directory.

In the Ubuntu system, the user's personal files and setting information are usually stored in the /home directory instead of the root directory. Therefore, if you divide the /home directory into a separate partition, the files in the /home directory will no longer be stored in the root directory, but will be stored in the /home partition.

Dual systems share files

mount command

In the Ubuntu system, you can use the mount command to mount a folder under the Windows system to a certain directory in the Ubuntu system. For example, you can create a directory (such as /mnt/windows) in the Ubuntu system as a mount point, and then use the following command to mount the folder under the Windows system to this directory:

sudo mount -t ntfs /dev/sda1 /mnt/windows

Among them, /dev/sda1 is the partition of the Windows system, and ntfs is the file system type of the Windows system partition. You can replace these parameters with your own partition and file system types. After mounting, you can access files in the Windows system under the /mnt/windows directory. It should be noted that in order to ensure the stability and security of the mount, it is recommended to mount with root privileges in the Ubuntu system, and uninstall the mounted folder when there is no need to access files in the Windows system. In addition, you also need to ensure that the folders that need to be shared in the Windows system have the correct permissions set so that they can be accessed in the Ubuntu system.

The mount can be either a disk or a folder in windows, for example:

sudo mount -t ntfs /dev/sda1 /mnt/windows -o ro,umask=022,gid=1000,uid=1000

Among them, /dev/sda1 is the partition of the Windows system, and ntfs is the file system type of the Windows system partition. /mnt/windows is the mount point in the Ubuntu system. The parameters after the -o option are some options when mounting. For example, the ro option indicates that the mount is in read-only mode, the umask option indicates the default permission for setting the mount point, and the gid and uid options indicate the user and group for setting the mount point.

To mount a folder in the Windows partition, you can replace /dev/sda1 with the path and folder name of the Windows partition, for example:

sudo mount -t ntfs /dev/sda1/MyFolder /mnt/windows -o ro,umask=022,gid=1000,uid=1000

In this way, the /dev/sda1/MyFolder folder will be mounted to the /mnt/windows directory.

It should be noted that if you want to mount a folder in the Windows partition, you must ensure that the folder has the correct permissions so that it can be accessed in the Ubuntu system. In addition, when mounting a Windows partition or folder, you also need to ensure that the partition or folder is not being used in the Windows system to avoid the risk of mounting errors or data loss.

Other ways of doing the above problem

Set up shared folders in windows

1. Open the file explorer, find the folder to be shared, and right-click the folder.

2. Select "Properties", and then select the "Sharing" tab in the pop-up window.

3. In the sharing window, select the "Share this folder" option and give the shared folder a name.

4. If you want to control other people's permission to access the shared folder, you can click the "Share Permission" button and set the corresponding permission.

5. Click the Apply and OK buttons to save the settings and close the share window.

You have now successfully set up a shared folder in Windows. Other computers can access this folder through the network, just need to enter the name of the shared folder and the network address of the Windows computer. For example, in an Ubuntu system, the following command can be used to mount a Windows shared folder:

sudo mount -t cifs //windows_computer_name/shared_folder /mnt/mount_point -o username=windows_username,password=windows_password

Among them, //windows_computer_name/shared_folder is the network address of the shared folder, /mnt/mount_point is the mount point in the Ubuntu system, username and password are the username and password in the Windows system, and are used to authorize the Ubuntu system to access the shared folder.

Use ntfs-3g tool to mount Windows partition or folder

The ntfs-3g tool allows the Ubuntu system to access the Windows file system in a read-write manner. The following are the steps to mount the Windows folder using the ntfs-3g tool in the Ubuntu system:

1. Open the terminal and use the following command to install the ntfs-3g tool:

sudo apt-get install ntfs-3g

2. Create an empty folder to mount the Windows folder, for example:

sudo mkdir /mnt/windows

3. Use the following command to mount the Windows folder and specify the ntfs-3g tool:

sudo mount -t ntfs-3g /dev/sda1 /mnt/windows

Among them, /dev/sda1 is the partition where the Windows folder is located, and /mnt/windows is an empty folder for mounting the Windows folder.

4. After the mount is successful, you can access the Windows folder in the Ubuntu system in read-write mode, for example:

sudo cp /home/user/file.txt /mnt/windows/

Where /home/user/file.txt is the file to copy and /mnt/windows/ is the target location in the Windows folder.

Notice

If you are unsure of the path where the Windows folder is located, you can use the following command in Ubuntu to see the mount point:

mount | grep ntfs

This command will list all mounted ntfs partitions or folders and show their mount points. Find the partition or folder where the Windows folder you want to mount is located, and replace it with /dev/sda1.

(Part of this article is obtained on the language model)

 

Guess you like

Origin blog.csdn.net/raw_inputhello/article/details/130021215