Tuesday, September 1, 2020

Install Windows 10 after Ubuntu / Linux


When I rebooted, Windows 10 was not on the Grub menu, but that was an easy fix. After booting into Ubuntu, simply use a terminal to run "os-prober" which should find Windows 10, then run "update-grub"
 
-----

Install Windows after Ubuntu/Linux

As you know, the most common, and probably the most recommended way of dual booting Ubuntu and Windows is to install Windows first and then Ubuntu. But what if you want to install Windows second on a computer with Ubuntu/Linux already installed?

This guide assumes that you have Ubuntu already installed on your system, and will guide you through installing Windows 7/8/8.1/10 when you have a working Ubuntu/Linux partition.

The problem here is that the Windows installer tends to overwrite Grub bootloader or whatever making only the Windows installation bootable. But the good news is that your Linux partition is untouched, including the original bootloader and the other Grub configurations. So restoring or recovering Grub is just a matter of running a few commands on the terminal.

Install Windows on a Separate Partition

If your Ubuntu installation occupies the entire hard drive, to be able to create free space for the Windows installation, you may have to shrink an existing partition using a disk utility like GParted. GParted comes preinstalled on Ubuntu LiveCD.

Boot into a Windows installation media and complete the installation

Once installed, because of Microsoft’s false assumption that there are no non-Microsoft operating systems you’ll be taken straight into Windows.

Restore / Reinstall Grub 2 with a Ubuntu Live Media

  1. Now boot into a Ubuntu Live/USB or CD.
  2. Open a terminal. (Ctrl + Alt + t)
  3. Use a command like lsblk, blkid or GParted to identify your Linux root, and boot partitions. You may or may not have a separate boot partition.
  4. Find Linux Partitions

     $ lsblk -f
     NAME                  FSTYPE     MOUNTPOINT
     sda                                                                            
     ├─sda1                ext4       /boot
     ├─sda2                ext4       /
     ├─sda3                ntfs       
    

    In my case,

    /dev/sda1 is the Linux boot partition

    /dev/sda2 is the Linux root partition

    /dev/sda3 is the Windows partition

  5. Setup a Chroot Environment

    Now we’ll be repairing our old grub bootloader in a chroot environment.

    Mount your root filesystem under /mnt

     sudo mount /dev/sda2 /mnt/
    

    If you’re using BTRFS (New Linux B-Tree File System) instead of EXT4, the above command should change to sudo mount -t btrfs -o subvol=@ /dev/sda2 /mnt/

    Run ls /mnt to verify that the correct partition is mounted. It should list the content of your root.

     $ ls /mnt
     bin   dev  home        lib64       media  opt   root  sbin  sys  usr  vmlinuz
     boot  etc  initrd.img  lost+found  mnt    proc  run   srv   tmp  var  vmlinuz.old
    

    Mount the boot partition. (SKIP if you don’t have a separate boot partition)

     sudo mount /dev/sda1 /mnt/boot
    

    If you have an EFI partition you should mount that also. It is basically a small FAT32 partition around 100mb. Please refer to the section on how to reinstall Grub in an EFI system.

    Bind these directories, so grub can detect other operating systems, like so.

     sudo mount --bind /dev /mnt/dev
     sudo mount --bind /dev/pts /mnt/dev/pts
     sudo mount --bind /proc /mnt/proc
     sudo mount --bind /sys /mnt/sys
    

    Let’s chroot into our existing Ubuntu/Linux system on the hard disk.

     sudo chroot /mnt
    
  6. Reinstall Grub.

     grub-install /dev/sda (specify the disk `/dev/sdX`, not `/dev/sdaX`)
     grub-install --recheck /dev/sda
     exit
    

    Once you’ve successfully reinstalled Grub, restart the computer. On next reboot Grub will be the default bootloader and you’ll be presented with a list of operating systems to choose from (Ubuntu and Windows, of course).

Reinstalling Grub in an EFI Based System

Reinstalling Grub bootloader in a UEFI based computer is no different from installing Grub on a legacy BIOS system. Here we also mount the EFI partition before chrooting, as we’d do with the boot partition.

Case #2
$ lsblk -f
NAME                  FSTYPE     MOUNTPOINT
sda                                                                            
├─sda1                ext4       /boot/efi
├─sda2                ext4       /
├─sda3                ntfs       

Here /dev/sda1 is the EFI partition and /dev/sda2 is the root.

sudo mount /dev/sda2 /mnt/

Mount EFI partition under ‘/mnt/boot/efi’

sudo mount /dev/sda1 /mnt/boot/efi

Forgetting to do so will result in errors being thrown while trying to execute grub-install: “/boot/efi does not appear to be the EFI partition”

As shown previously, bind the /dev, /dev/pts, /proc, and /sys directories.

Finally,

sudo chroot /mnt
grub-install
exit

In some rare occasions, Grub might not detect Windows. In that case just login to Ubuntu (installed one on the disk, not the bootable Live USB/CD) and execute,

sudo os-prober
sudo update-grub
sudo reboot

Happy Dual-Booting!


 

Wednesday, August 5, 2020

Making an Image of a Disk (or Partition) Using dd WITHOUT Including Extra Empty Space

This write-up helped me a lot with this.

I have a Raspberry Pi that gets a lot of use as a media control station, and as a result, it periodically needs to be re-imaged. This is a lot faster and easier than re-installing everything from scratch and then setting up Mythtv, all my network settings, etc. So, a long time ago I used dd in Linux to make an image of a fresh install with all the basic things setup for my network, including Mythtv client. That install was on a microSD card that was 8 GB, so the resulting .img file was 8 GB even though at least half of that was unused. When I tried to write that image to a different 8 GB microSD card, it failed because of insufficient space. If one card had even one bit less (for reasons I do not know), it would be too small. What I needed was to get rid of all that empty space in the .img file.

Write the .img file to a larger memory card that will hold all 8 GB. Then use GParted to shrink the partition that has all the unused space in it to a reasonable size. Now, use sudo fdisk -l -u=sectors to find the number of the last sector used by the last partition.

Disk /dev/sdb: 7.4 GiB, 7960788992 bytes, 15548416 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00ed4

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1         4096   147455   143360   70M  c W95 FAT32 (LBA)
/dev/sdb2       147456  6348892  6421187  7.4G 83 Linux
 

Make a new .img file from this memory card with the smaller partition. The key here is the parameter "count."

sudo dd if=/dev/mmcblk0 of=NO_WASTED_SPACE.img bs=512 count=6348892

where the count value is the number of the last sector of the last partition you saw in the fdisk listing. That makes dd stop reading anything after the last partition, namely all that extra empty space. Now you have an image file that is just the size you need, it won't take up extra storage space because of the unused space in the image, and when you write the image to a disk (memory card), you won't get errors and failure because the image is larger than the card you are trying to write it on.
 
Something important I learned, the sector size on the block device (memory card) shown via fdisk was 512. When telling it the sector to stop on, you have to make sure the input and output blocksize (bs=) is the same as the sector size, in this case 512. The first time I tried it, the image file was turning out to be huge because I use a block size of 4096 (bs=4096), but the number I used as the last sector to read (count=) was based on a sector size (block size) of 512. When I switched bs back to 512 (I believe the default), it worked fine. Now my image file is 3 GB instead of 8 GB, less space sitting on my hard disk drive, and it won't be picky writing to any device with 3 GB space or more.

Thursday, October 29, 2015

Print Enlarged Documents & Images with PDFPoster or PDFImages & Rasterbator.net

Two convenient methods of printing enlarged document or images follow:

1. PDFPoster is a command line utility for linux that will enlarge an input PDF document so that you can print it out on many sheets of paper.

2. PDFImages is a command line utility for linux that extracts the images from a PDF document. Then, you can use that image at http://Rasterbator.net, which will configure the image for printing an enlarged version on many sheets of paper. Pretty slick.

Tuesday, August 4, 2015

Nicholson bench... more progress


Today, I had to redo the top braces that go horizontally between the tops of each end/leg assembly because I mistakenly made them the wrong dimensions (1/4" short) based on the original design before we made a few minor modifications (changing it to be a split-top bench).

After doing that, I milled the "under-aprons" which beef up the thickness of both aprons. Each got planed on the face that was crowning, then straight-lined and ripped. I clamped one apron in place onto the legs and marked the under-apron to fit between the legs.

Next, we glued up each of the two under-aprons to its corresponding apron using PVA glue (Titebond original). We had to work fast. I spread the glue onto the planed side of the under-apron, flipped it into place, put two clamps on, adjusted it to be flush on what will be the top edge, & drove two screws in to hold the alignment. Then I repeated the process on the other pair.

After gluing and screwing both sets, we stacked them up and began putting clamps on. While that was setting up, I glued and screwed the new top braces into the leg assemblies with Little Brown glue.

Next will be getting the top pieces planed, ripped, and cut to length, then glued up to their "under-top" pieces like I did with the under-aprons.

Clamping apron to legs to check fit and to use for marking under-aprons

Clamping apron to legs to check fit and to use for marking under-aprons
Clamping glued aprons and under-aprons
Leg assemblies with top brace installed

Thursday, July 30, 2015

Nicholson Bench Leg Assembly

We did last-minute tune-up work on the legs today, like cleaning up the notches in the legs where the lower cross braces attach. I had to power plane the cross braces a bit more to make them fit flush, and one of the leg ledges where the apron sits required a little chisel work to trim a little more. Then we "sized the joint" by smearing some glue (in this case, warmed hide glue... specifically Little Brown Glue) on the joints and letting it sit for several minutes. This helps to seal the areas of end grain so they won't absorb all the glue and "starve" the joint. After it partially dried, we applied additional glue to all those surfaces, then assembled and clamped the parts. In this case, screws were added where called for.

I also finished drilling the 19 dog holes in the remaining apron. We made good progress today.




Thursday, July 23, 2015

New Work Apron

When I began woodworking, the only apron I had was one from the kitchen. It wasn't the greatest kitchen apron, but it certainly wasn't well-suited for the shop. It was better than nothing... barely, so that's what I've been wearing. By far, my biggest complaint is the strap that goes around my neck to hold the apron up. I can't stand the feeling of a strap pulling on the back of my neck all the time. It's a serious distraction and drives me nuts. The kitchen apron also lacked appropriate pockets and strength for a shop apron.

I've seen handmade shop aprons from a maker in Texas that seem well made with waxed (or non-waxed) canvas, leather straps that cross in the back and do not go around the neck, and custom sized pockets to fit the phone and other utensils that the wearer wants to always have at hand. The price of these aprons reflected their quality and kept me from joining in on the quality apron fun... until I proposed a joint project with my wife.

She bought some canvas at a discount fabric store, and we bought some leather (buffalo) straps, a leather hole punch, slides, D-rings, copper rivets, and a rivet set thingy.

After discovering that her machine would not work with a double needle (which would've made the double stitching easier and more precise), she resolved to do the work with a single needle. She laid out the apron according to my body and how I wanted it to fit and proceeded to sew the edges and the pockets.

Upon completion of the sewing, I cut the leather to length, installed the slides for adjustability, put the D-rings in the appropriate places, and attached the leather with copper rivets. The apron is wearable now, but I plan to put copper rivets at all pocket corners and stress points for durability. They're (rivets) surprisingly easy to install. The apron that inspired mine has a separate strap that goes horizontally from one side of the apron to the other with a clip. It's a butt strap. I'm not certain I will put this on mine because, so far, it seems superfluous.

Oh, I almost forgot to mention... I also got a bar of paraffin wax and rubbed it across the outside of the canvas, then melted it into the fabric with my heat gun (it's good for something besides reflowing solder on my PS3). Not only does the wax make the apron water, dirt, & glue resistant, it also gives it a "broken in" look that I like.
Added the slides for adjusting the shoulder straps

Shoulder straps riveted to slides

Punching holes in the leather straps (the ones that hold the D-rings on the top of the apron)

Setting the copper rivets
Setting the copper rivets

Cutting excess rivet shank

Finished rivets after blunting the cut shank with the rivet tool

Comfy, durable, & STYLISH apron ready to catch some wood shavings and dust

Tuesday, July 21, 2015

Design modifications, legs, hardware

Since my last post, we've made some modifications to the design in SketchUp such as increasing the height. We're also going to use "two-by" material for the apron backer instead of "one-by." The bench will now be a split-top with 2" between the two top boards, necessitating eight cap screw holes in the top instead of six (two on each end of each top board).

The glue on the legs was given too much time to dry before cleaning up, so the messy edges were shaved on the rip saw. I used a stacked dado set on the table saw to make the notches in the legs for the lower cross braces. I cut and milled the upper ends, lower cross braces, and top leg braces to size.

I have acquired the cap screws, washers, and nut plates, and I've also purchased four Gramercy Holdfasts.

The legs need to be assembled next. I have dog holes drilled in one apron, but many holes are left to drill in the other apron and the two top boards.