Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Arch Linux in a virtual machine

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how to install Arch Linux in the virtual machine, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to install Arch Linux in the virtual machine. Let's take a look.

Environment

VMware Workstation 15.0

Arch Linux 2020.05

How to download ArchLinux

Create an Arch Linux virtual machine

The version of the virtual machine can choose "other …"

Install the operating system

Boot the interface and select the first item

After booting, you can see that you have entered the Live environment.

Check to see if you are connected to the Internet

Check whether the network card has obtained the IP address:

Root@archiso ~ # ip ad 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00 scope host lo valid_lft forever preferred_lft forever inet6:: 1128 scope host Valid_lft forever preferred_lft forever2: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:83:ed:00 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.43.154/24 brd 192.168.43.255 scope global dynamic noprefixroute ens33 valid_lft 1706sec preferred_lft 1481sec inet6 fe80::456b:5cf2:4baa:efd8/64 scope link valid_lft forever preferred_lft forever

Then ping the external network to see if you can surf the Internet:

Root@archiso ~ # ping www.baidu.comPING www.a.shifen.com (180.101.49.12) 56 (84) bytes of data.64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=128 time=20.3 ms64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=128 time=20.5 Ms ^ C-www.a.shifen.com ping statistics-2 packets transmitted, 2 received, 0 packet loss Time 1001msrtt min/avg/max/mdev = 20.252 / 20.391 / 0.139 ms

If you can surf the Internet, let's go to the next step.

Create Partition

Here we are divided into two districts, which are:

Swap: 512MB/: all remaining spaces

The total capacity of sda disks is 20GB.

Root@archiso ~ # fdisk-l

Create a partition:

Format the partition and mount the partition

/ dev/sda1 partition, create a swap partition, and enable it.

Root@archiso ~ # mkswap / dev/sda1Setting up swapspace version 1, size = 488MiB (511700992 bytes) no label, UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3root@archiso ~ # swapon / dev/sda1

Format the sda2 partition to the xfs file system and mount the partition to the / mnt directory:

Root@archiso ~ # mkfs.xfs / dev/sda2root@archiso ~ # mount / dev/sda2 / mnt

Modify mirror source

Go to the / etc/pacman.d directory and modify the mirrorlist file. By default, the mirrorlist file contains many source addresses, which will cause slow downloading of the package. We only need to enable the Chinese source address:

Root@archiso ~ # cd / etc/pacman.droot@archiso / etc/pacman.d # lltotal 25drwxr-xr-x 4 root root 320 May 6 2020 gnupg-rw-r--r-- 1 root root 495 May 6 2020 mirrorlistroot@archiso / etc/pacman.d # mv mirrorlist mirrorlist.backroot@archiso / etc/pacman.d # cat mirrorlist.back | grep-A1 China | grep-v'\ -'> mirrorlist

Installation must include the software package root@archiso ~ # pacstrap / mnt base linux linux-firmware dhcpcd vim openssh xfsprogs man net-tools to generate fstab files

Use the genfstab command to generate a configuration file. The-U command is used to set UUID.

Root@archiso ~ # genfstab-U / mnt > > / mnt/etc/fstab root@archiso ~ # cat! $cat / mnt/etc/fstab# Static information about the filesystems.# See fstab (5) for details.# # / dev/sda2UUID=ed6bd242-34fe-43b6-bb0a-08af6cdb28e8 / xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k Noquota 0 0root@archiso / dev/sda1UUID=ee7fa952-a403-4b6e-9b15-fddc21246fc3 none swap defaults 0 0root@archiso ~ #

You can see that both the swap partition and / partition have been written to the fstab configuration file.

Change the root directory root@archiso ~ # arch-chroot / mnt [root@archiso /] # change the time zone

Change the time zone to Asia and Shanghai. And synchronize time to hardware time.

[root@archiso /] # ln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime [root@archiso /] # hwclock-w set localized text encoding

Edit / etc/locale.gen add the following:

[root@archiso /] # echo "en_US.UTF-8 UTF-8" > > / etc/locale.gen [root@archiso /] # echo.UTF-8 > / etc/locale.conf set root password [root@Archone /] # passwd rootNew password:Retype new password:passwd: password updated successfully [root@Archone /] # set boot item [root@Archone /] # systemctl enable dhcpcd [root@Archone /] # systemctl enable sshd install and configure grub2 boot

Install grub2

[root@Archone /] # pacman-S grub- noconfirm [root@Archone /] # grub-install / dev/sdaInstalling for i386-pc platform.Installation finished. No error reported.

Export grub configuration file to / boot/grub/grub.cfg

[root@Archone /] # grub-mkconfig-o / boot/grub/grub.cfg configuration completed

Restart the system

[root@Archone /] # exitroot@archiso ~ # reboot

As you can see, it has entered the system after reboot.

Modify the ssh configuration file to allow root users to log in to ssh

It is found that users using root cannot ssh remote login to the system because root users are not allowed to log in in the configuration file:

[root@arch-one ~] # sed-I 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' / etc/ssh/sshd_ config[ root @ arch-one ~] # systemctl restart sshd

This allows ssh to log in to the server remotely.

Install Gnome Desktop Environment # installation prompts. Enter by default. [root@arch-one ~] # pacman-S xorg xorg-server gnome [root@arch-one ~] # systemctl enable gdm NetworkManagerCreated symlink / etc/systemd/system/display-manager.service-> / usr/lib/systemd/system/gdm.service.Created symlink / etc/systemd/system/multi-user.target.wants/NetworkManager.service-> / usr/lib/systemd/system/NetworkManager.service.Created symlink / etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service-> / usr/lib/ Systemd/system/NetworkManager-dispatcher.service.Created symlink / etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service-> / usr/lib/systemd/system/NetworkManager-wait-online.service.

Restart the operating system

[root@arch-one ~] # reboot

This is the end of the article on "how to install Arch Linux in a virtual machine". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to install Arch Linux in the virtual machine". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report