Skip to main content
Topic: copy -ax / /mnt (Read 2047 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

copy -ax / /mnt

I didn't know this and I found it on arch-wiki https://wiki.archlinux.org/index.php/Offline_installation
I don't think cp has this option in other linux, it copies -a (all) with the exception of live system things that should not be copied.
So you have a live system and you want to install it to a mounted partition /mnt
Simply cp -ac / /mnt and the whole system transfers as installed (no network required).  Then you chroot to it, edit fstab, install a kernel, do your bootloader adjustments, and you are done.  I guess, and since we were talking about this in another thread, get dbus to throw up a new machine-id and replace the one from the live session.

The wiki though has a note that some people dispute the validity.  I tried it in a vm and it worked great.
Anyone cares to comment?  It actually worked pretty fast from just being cp and not rsync.  I am curious what the source for cp shows for the x option, what is in the exclude list.  I suspect that if you mount the new partition in a folder other than /mnt and somewhere else it will not be excluded and run circles till it fills up.



Quote
cp
‘-x’
‘--one-file-system’

    Skip subdirectories that are on different file systems from the one that the copy started on. However, mount point directories are copied.

Re: copy -ax / /mnt

Reply #1
As far as i know sta.li may be installed only this way
ARMtix

Re: copy -ax / /mnt

Reply #2
This is how I once did something similar to that wiki page using just an uninstalled Parabola iso file, it resulted in a bootable system. But watch out for weird stuff (mis)using installer images, they often have extra packages and scripts, and Parabola had some incorrect file permissions as noted in the code box. Hopefully I didn't miss out any steps when I wrote these notes . :D
I installed Artix normally from a USB so don't have a guide for that.
Code: [Select]

$ sudo mount -o loop ~/Downloads/parabola-openrc-2017.09.30-dual.iso /media/squashfs/
$ cp /media/squashfs/parabola/i686/root-image.fs.sfs ~/test
$ sudo umount /media/squashfs
Wipe and format the partition to install on:
$ sudo mkfs.btrfs -f /dev/sdaX
Make a note of the UUID, need this for the fstab later although blkid will tell you.
$ sudo mount -t btrfs /dev/sdaX /mnt
$ sudo su
# unsquashfs -d /mnt/sq/ /home/me/test/root-image.fs.sfs
# exit
Other liveCD's I've tried unpack the filesystem, but a further step was required for the Parabola dual iso. Mount root-image.fs and copy the contents out.
$ sudo mount -o loop /mnt/sq/root-image.fs /media/squashfs/
$ ls /media/squashfs/
bin  boot  dev  etc  home  lib  lost+found  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
$ sudo cp -a /media/squashfs/* /mnt
$ sudo umount /media/squashfs
At some point the root-image.fs can be deleted, but it can be kept around for a while in case another attempt is required.
--: $ sudo rm -R /mnt/sq
fstab is an empty file here, create / edit fstab.
Security note: there are many directories and files that have the wrong group and owner, they should be root.
This image is intended as an installer CD, not a regular installation. One liner to fix this: (grep -v works the same as ag -v)
$ sudo chown root:root  `sudo find /mnt -user $USER | ag -v "home/parabola"`
CHROOT TO PARABOLA:
$ sudo su
# for d in dev sys run proc; do mount --bind /$d /mnt/$d; done
# chroot /mnt
# pacman -Q>/Q.txt - create original package list - sudo is installed.
# /usr/sbin/useradd --create-home --groups wheel,rfkill,network,audio,optical,floppy,power $USER
# visudo -f /etc/sudoers.d/my_sudo
<yourusername>  ALL=(ALL) ALL
# /usr/sbin/userdel -r parabola
# /bin/passwd me
# passwd -S root
root NP 09/19/2010 -1 -1 -1 -1
# passwd -dl root
passwd: password expiry information changed.
# passwd -S root
root L 09/19/2010 -1 -1 -1 -1
(Don't lock the root account unless sudo is installed)
/etc/locale ??????
LANG=en_US.UTF-8 - That was OK for me
# echo somename >/etc/hostname
# mv /etc/localtime /etc/localtime.utc.orig
# ln -sf /usr/share/zoneinfo/GB /etc/localtime
Edit /etc/hosts:
127.0.0.1       localhost.localdomain   localhost       somename
::1             localhost.localdomain   localhost       somename
There is no /boot/vmlinuz* so mkinitcpio won't work.
Download and install a Parabola kernel package manually from a mirror repo, it should have /boot/vmlinuz in it.
# pacman -U /somewhere/linux-libre-pae-4.15.17_gnu-1-i686.pkg.tar.xz
# exit
# for d in dev sys run proc; do umount /mnt/$d; done
# exit
$ sudo umount /mnt
Run update-grub in the existing Linux OS on the other partition
$ sudo update-grub
It created an Arch menu entry in /boot/grub/grub.cfg.