Systemback changes the default storage directory /home and creates a Linux image larger than 4G in Ubuntu18 tutorial


Preface

Recently, the company is responsible for packaging the Linux Ubuntu18 system and the program environment installed by the company into ISO files to facilitate subsequent standard disk production. However, I encountered various problems during the packaging process, so I recorded my pitfalls and solutions here.

1. First of all, the Linux system and the large program environment content cause the final generated ISO file to be much larger than 4G (eventually 13G), so it cannot be packaged by conventional methods . There are also many ISO production tutorials for larger than 4G on the Internet (using Systemback), so this problem can be easily solved.

2. I looked for Systemback installation tutorials on the Internet, but found that Systemback does not support the Ubuntu18 system by default . This problem can be solved by changing some command line parameters.

3. Since my total disk space is 64G, which is not very large, there will be insufficient disk memory when generating the ISO file . When using Systemback to generate ISO, an intermediate file will first be generated.sblive, and the process of generating this generated file will generate many cache files, resulting in insufficient disk space. For example, the hard disk I use is 64G in size, of which there is 25G free space in the /home directory, and the final generated sblive file should be about 13G, which is theoretically enough (25G>13G). However, systemback will generate many cache files during this process, causing the required disk space to be much larger than 13G, which also exceeds the 25G free space in the /home directory.

I didn't pay attention when I generated the sblive file for the first time. I thought there was enough disk space, so I hung up the computer and let Systemback run there. As a result, the disk space finally ran out and Linux couldn't start. In the end, I also found a way to change systemback's default working directory /home to my own USB flash drive, so that the sblive file could be generated directly in the USB flash drive (I don't believe that a 64G empty USB flash drive is not enough!).

If you want to try to generate sblive files directly in the /home directory, then I also recommend that you use the df -h command to check the changes in the size of your disk space while Systemback is running. If you find that it is almost full, you need to terminate Systemback in time. run.


以下是本篇文章正文内容,仅供参考

1. Install Systemback on Ubuntu18 system

Part of the content is referenced from online tutorials.
Reference link: Ubuntu system image production and installation based on systemback

If you are also an Ubuntu 18 system, this should happen when you follow the online tutorial to install Systemback:
Insert image description here

This is because Systemback does not support the Ubuntu18 version.
If you want to install Systemback on Ubuntu18 system, you need to do the following:

1. Remove the previously established warehouse connection (if one was established)

sudo add-apt-repository --remove ppa:nemh/systemback

2. Establish a connection through a key

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 382003C2C8B7B4AB813E915B14E4942973C62A1B

3. Add target software repository

sudo add-apt-repository "deb http://ppa.launchpad.net/nemh/systemback/ubuntu xenial main"

4. Update system software repository

sudo apt update

5. Install systemback

sudo apt install systemback

At this point, Systemback under the Ubuntu18 system has been successfully installed.

2. Production of system image

1. Start Systemback

Search and start Systemback directly in the Linux search bar:

Insert image description here
Or start it through the command line (although I can't start it from the command line):

 sudo systemback

2. Modify the default storage directory /home

If you are sure that there is enough disk space in your /home directory (when I generated a 13G sblive file, I needed at least nearly 28G of memory space), then there is no need to change the storage directory. If it is not enough, you need to perform the following steps:

After starting Systemback, you can see that the default storage folder is the /home directory, and when you select other directories, they are basically red crosses and cannot be selected.
Insert image description here
At first, I thought it would be enough to just connect an external USB flash drive with enough space and then change the storage directory to the directory where the USB flash drive is mounted. But later I found that this path also didn’t work, and the U disk format was not selectable (red cross).
After some research, I found the following passage on the official website

You can also set the Working directory where you store live images and isos. This directory must be a writable linux filesystem - no fat, exfat, fat32 nor ntfs directories or partitions can be used for storage.

What this means is that the directory folder selected for writing cannot be in fat, exfat, fat32 or ntfs format, and must be a writable Linux file system. Only then did I suddenly realize that because my USB flash drive was formatted as NTFS, no wonder I couldn’t choose.

The solution is as follows:

1. Insert the U disk into the host with Linux system, right-click and select Format
Insert image description here
2. Select Ext4 as the format type:
Insert image description here
After formatting to Ext4, our Systemback can recognize our U disk.

3. In order to facilitate viewing the U disk directory, I also remounted the U disk directory ( optional operation ):

First check your USB disk information

sudo fdisk -l

After entering this command, you can roughly find the corresponding address based on the size and available space of your USB flash drive.

For example, the address of my USB disk is /dev/sdb, and it is mounted under /media/username/U by default. In order to easily view the contents of the U disk, I remounted it to /home/Udisk/ (Udisk does not need to be created by myself, it will be created by itself)

Use the umout command to cancel the mount/media/username/U :
Insert image description here

The mount command remounts to/home/Udisk/:
Insert image description here

At this time we can select the mounted Udisk folder in the Systemback storage folder (you can see the black Udisk/ here as an optional directory, the red cross Udisk is the folder I created before, and it turns out that When mounted using the mount command, it will create the folder itself)Insert image description here

At this point, the directory change has been successful.

3. Generate sblive file

Since I don’t have a screenshot, here is a network diagram I found online . The process is the same.

First, you need to convert1Change the working directory /home in to your U disk file directory /home/Udisk ,2The system name in can be customized. If you not only want to back up the bare system, but also want to back up the program environment, you also need to check " Include user data files "! ! !
Select after setting is completecreate new, you can directly generate the sblive file on the USB disk.
Insert image description here

4. Move the sblive file in the USB flash drive back to the Linux host

After a long wait, the sblive file was also generated on our USB flash drive, but we want to move it back to the Linux system. The reason for moving back to the Linux host is because our USB flash drive will be used as a boot disk, so we must first save the sblive back to the Linux host (any host with Systemback installed will do), and then use the Systemback tool to save the sblive The file is written to the startup disk.

Although the process of creating an sblive file requires a large cache space, after the creation is completed, Systemback will automatically delete the excess cache, leaving only a 13G sblive file, so it can be moved back to the original 25G /home directory.

sudo mv /home/Udisk/Ubuntu_ISO.sblive /home/Ubuntu_ISO.sblive

5. Make a boot disk

Since I don’t have a screenshot, here is a network diagram I found online . The process is the same:
Insert image description here

After inserting the U disk, the Write target below will display your U disk. After checking it, select the sblive file you just moved to Linux in the upper right corner and clickWrite to target, Systemback will write the sblive file directly to your USB flash drive to create a USB boot disk. (Note that hereConvert to ISOIt should be gray because it is larger than 4G and cannot be converted. but we can skipConvert to ISOSteps to let Systemback directly help us generate a USB boot disk)

At this step, the USB boot disk has been created. Systemback automatically saves us the process of converting to ISO and directly creates a boot disk from sblive files larger than 4G. If your goal is just to create a boot disk, you can skip sections 6 and 7 and go directly to the third section to see how to install it.

If you want a separate ISO file, you still need to use the content in sections 6 and 7.cdrtoolsTool to convert sblive files larger than 4G into ISO files.

6. (Optional) How to convert sblive to ISO file

Enter the home directory:

cd /home

6.1 Create sblive folder

mkdir sblive

6.2 Unzip the .sblive file obtained in the previous step to the sblive folder

tar -xf /home/target_iso.sblive -C sblive

6.3 Rename related files

mv sblive/syslinux/syslinux.cfg sblive/syslinux/isolinux.cfg
mv sblive/syslinux sblive/isolinux

6.4 Install cdrtools tool

sudo apt-get install aria2
wget https://nchc.dl.sourceforge.net/project/cdrtools/alpha/cdrtools-3.02a07.tar.gz
tar -xzvf cdrtools-3.02a07.tar.gz
cd cdrtools-3.02/
make
sudo make install

6.5 When installing the cdrtools tool, you may encounter resources being occupied. Execute the following command and install again.

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

6.6 Return to the upper directory

cd ..

6.7 Start image production

sblive at sblive.iso can be modified to the target name

/opt/schily/bin/mkisofs -iso-level 3 -r -V sblive -cache-inodes -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o sblive.iso sblive

Next, just wait for the conversion to complete (make sure there is enough space in the system for the ISO file conversion process).

7. (Optional) How to use ISO files to create a USB boot disk

If you don't want to make a USB boot disk directly through Systemback, but want to use an ISO image to make a boot disk, then you can use the Ventoy tool to do it under Windows.

Ventoy tool download address:
link: https://pan.baidu.com/s/1ezq_eEqhMgjFonrLvdcFTg
extraction code: 4DEF

Insert image description here
After unzipping, just run Ventoy2Disk.exe. The tool will detect the U disk device on its own. Select the device and clickInstallYou can install the boot tool on the USB flash drive (it will be automatically formatted).

After the installation is completed, just put your ISO file into the USB flash drive. At this time, your USB flash drive has become the boot disk.

3. Startup disk installation system

Insert the USB flash drive into the host where you want to install the system, press the keyboard shortcut to enter the Boot interface, and set the USB flash drive as the first startup item in the Boot interface.
Here, the shortcut keys of each host's Boot interface are different after startup. You can check the information online by yourself.

1. Select the installation system

Insert image description here
Here, the interface of my USB boot disk is garbled (I have seen this happen to other people, and I don’t know why), but it has no effect.
The original picture from others on the Internet is as follows:
Insert image description here
The first option is to use the USB flash drive as the system, that is, run the Linux system directly on the USB flash drive for temporary office use. (Note that the Linux system on the USB flash drive cannot save any modifications made by the user. After you restart the next time, you will find that all the new or modified content you have added or modified has been reset when you enter the Linux system on the USB flash drive.)

The second option is system installation, so here we choose the second option.

2. Enter the installation interface

Insert image description here

Here you are asked to enter the password of your parent system and log in as required.

After logging in, you will see the following interface:
Insert image description here
fill in your new system user login name and password here.
The new user's full name can also be used as the login account. Although the first letter must be capitalized, you can change the user's full name in the account column in the upper right corner of the Linux interface after installing the system, so there is no impact.

Insert image description here
The next step is to install the partition.
Generally, it needs to be divided into three areas, namely boot, swap and root directory/
space size to decide by yourself.

I recommend checking the option to pass user configuration files and user data, and install the GRUB2 boot program, otherwise the system may not be installed properly.
When installing the GRUB2 boot program, you need to have a node mounted on /boot/efi, so the three partitions I finally selected are/boot/efi , swapand/.
Replacing /boot with /boot/efi seems to have no effect, and in the end the system can install and run the program normally.

3. Installation successful

Follow the prompts to install:
Insert image description here
Insert image description here
wait for installation and then restart.
Some users may prompt you to unplug the startup disk on the restart interface. Just follow the prompts to unplug it, otherwise you may be stuck on the Ubuntu loading interface.

Summarize

Although there are many tutorials on making ISO boot disks larger than 4G on the Internet, there are still many details that are not covered. This tutorial is only a supplement. If there are any errors, please point them out in the comment area.

Guess you like

Origin blog.csdn.net/Bartender_VA11/article/details/126498468