Alternate install method via debootstrap script - 1000001101000/Debian_on_Buffalo GitHub Wiki
Instead of booting the device into the Debian Installer, this method generates a Debian disk image which can then be written to a hard disk. This approach has a few advantages:
- It is faster than running the installer on the device in most instances
- It works for devices with too little memory to run the installer successfully (LS-XL,LS-CHLv2,LS-WTGL)
- working with a disk image makes it easier to start over if something goes wrong with your install
- Allows older devices to use disks larger than 2TB (LS-GL, Terastation II and likely other older devices)
This method is based around debootstrap which is a Debian tool, it has been tested in Debian 9 and Debian 10. It should work from a Debian live environment or VM and may work from other Debian based distros like Ubuntu. It also depends on having access to most of this repository rather than just the installer files so you'll want to start by cloning the repo.
To prepare run the following:
apt-get install qemu-user-static debootstrap qemu-system-arm git clone --depth 1 https://github.com/1000001101000/Debian_on_Buffalo cd Debian_on_Buffalo/Tools/debootstrap
The script is named generate_disk_image.sh before Running the script you need to adjust some of the variables at the beginning to match your device and desired setup.
target This is where the system will temporarily mount the image while it is being built. The default should be fine unless you already use that directory for something else.
target_hostname The hostname the resulting system will have, you can set this to whatever you want.
machine This is model device the image is for and controls some device specific elements. See the table below for the list of supported options.
arch This is the Debian architecture that the image will use. This must match the architecture of the target machine. See the table below for the proper value for your device.
distro The version of Debian being installed. Currently Stretch (Debian 9) and Buster (Debian 10) are supported and have been tested.
target_rootpw The password for the root user on the resulting system. Note that root logins over SSH will be disabled by default.
target_user username for the default user created by the install process.
target_userpw password for the default user.
boot_size size in Megabytes of the boot volume. The oldest devices need this to be less than 1GB. The default of 512M is usually more than enough.
swap_size size of the swap volume. How much swap you need depends on what applications you plan to run. The default of 1GB is usually enough for most use cases.
root_size The size of the root filesystem. How much you need depends on your use case but 2GB is about the smallest this can be without running into space issues, 5GB is usually more than enough unless you don't plan to create a separate data partition.
use_raid Creates RAID1 arrays for boot,swap and rootfs instead of plain partitions. Use this if you intend to use multiple disks in your device. See instructions below for how to add additional disks to the resulting system.
Machine Values | Architecture |
---|---|
Buffalo Linkstation LS210D | armhf |
Buffalo Linkstation LS220D | armhf |
Buffalo Linkstation LS410D | armhf |
Buffalo Linkstation LS420D | armhf |
Buffalo Linkstation LS421D | armhf |
Buffalo Linkstation LS441D | armhf |
Buffalo Terastation TS1200D | armhf |
Buffalo Terastation TS1400D | armhf |
Buffalo Terastation TS1400R | armhf |
Buffalo Terastation TS3200D | armhf |
Buffalo Terastation TS3400D | armhf |
Buffalo Terastation TS3400R | armhf |
Buffalo Nas WXL | armel |
Buffalo Terastation TS-XEL | armel |
Buffalo Terastation Pro II/Live | armel |
Buffalo Linkstation LS-XL | armel |
Buffalo Linkstation LiveV3 (LS-CHL) | armel |
Buffalo Linkstation LS-CHLv2 | armel |
Buffalo Linkstation LS-QL | armel |
Buffalo Linkstation LS-QVL | armel |
Buffalo Linkstation LS-VL | armel |
Buffalo Linkstation LS-WSXL | armel |
Buffalo Linkstation LS-WTGL | armel |
Buffalo Linkstation LS-WVL | armel |
Buffalo Linkstation LS-WXL | armel |
Buffalo Linkstation LS-XHL | armel |
Buffalo Linkstation Mini | armel |
Buffalo Linkstation Mini (LS-WSGL) | armel |
Buffalo Linkstation Pro/Live | armel |
Buffalo/Revogear Kurobox Pro | armel |
Buffalo Linkstation LS510D | armhf |
Buffalo Linkstation LS520D | armhf |
Buffalo Linkstation LS710D | arm64 |
Buffalo Linkstation LS720D | arm64 |
Note: The LS500 entries are for creating an image which can run from within the stock firmware via chroot
Once all the variables have been set you can run the script:
./generate_disk_image.sh
Although it is usually faster than running natively on the device, the second stage runs under qemu and takes several minutes.
Once the script finishes you will have a disk image file named debian_$distro_$arch.img
Once you have your disk image you can write it to your disk by connecting it to your PC via SATA or SATA to USB adapter and using dd or pv:
dd if=debian_buster_armel.img of=/dev/sdx bs=4k
or
pv debian_buster_armel.img > /dev/sdx
It's important the you choose the correct disk, you can determine which is which by running lsblk
This process skips a few steps covered by the full Debian installer, here on some notes on steps you can take to complete the installation.
To change the language/localization settings:
apt-get install locales dpkg-reconfigure locales
If you plan to use drives larger than 2TB you'll need to convert your partition table to GPT. Most devices will happily boot from either MBR or GPT partitions without issue. The oldest supported devices (LS-GL, LS-WTGL, TS2PRO, etc) will only boot from MBR or Hybrid partition tables. Fortunately gdisk makes converting to both types fairly simple. See below for how to convert to both types.
For a detailed explanation of why this is needed and how it works see: https://www.rodsbooks.com/gdisk/hybrid.html
~# gdisk /dev/sda GPT fdisk (gdisk) version 1.0.3 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sda.
Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): r Recovery/transformation command (? for help): h WARNING! Hybrid MBRs are flaky and dangerous! If you decide not to use one, just hit the Enter key at the below prompt and your MBR partition table will be untouched. Type from one to three GPT partition numbers, separated by spaces, to be added to the hybrid MBR, in sequence: 1 2 3 Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N Creating entry for GPT partition #1 (MBR partition #1) Enter an MBR hex code (default 83): Set the bootable flag? (Y/N): N Creating entry for GPT partition #2 (MBR partition #2) Enter an MBR hex code (default 83): Set the bootable flag? (Y/N): N Creating entry for GPT partition #3 (MBR partition #3) Enter an MBR hex code (default 83): Set the bootable flag? (Y/N): N Recovery/transformation command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sda. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) The operation has completed successfully.
~# gdisk /dev/sda GPT fdisk (gdisk) version 1.0.3 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): x Expert command (? for help): u Type device filename, or press <Enter> to exit: /dev/sdb Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. Expert command (? for help): q
~# mdadm /dev/md90 --grow --raid-devices=2 --add /dev/sdb1 mdadm: hot added /dev/sdb1 raid_disks for /dev/md90 set to 2 ~# mdadm /dev/md91 --grow --raid-devices=2 --add /dev/sdb2 mdadm: hot added /dev/sdb2 raid_disks for /dev/md91 set to 2 ~# mdadm /dev/md92 --grow --raid-devices=2 --add /dev/sdb3 mdadm: hot added /dev/sdb3 raid_disks for /dev/md92 set to 2
~# mdadm --detail /dev/md9[012] | grep State\ : State : clean State : clean State : clean
create new data array?